
Week 4 - Day 2 - quizregularexpressions
Authored by Clinton Cunha
Computers
University
Used 12+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What will the following code print?
Any line containing 'From'
Any line that starts with 'From'
Any line that starts with 'From:'
Any line containing 'From:'
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following options is the correct way to import the regex library?
import regex
import re
import Regex
import Re
3.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Which of these option(s) will match digits in a string? Select all that apply.
[0-9]
\D
\d
\w
4.
MULTIPLE SELECT QUESTION
2 mins • 1 pt
Which of these lines will be matched when the following code is run?
It will cost you $1.00
From: stephen.marquard@uct.ac.za $a
$2.50 is your change
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
True or false? The following code will match only the first email(up to the @ sign) in the string?
True
False
6.
MULTIPLE SELECT QUESTION
2 mins • 1 pt
Which of the following options will the regular expression ^X-.*: [0-9.]+ match?
X-DSPAM-Probability: Accurate
X-DSPAM-Confidence: 0.8475
X-Wolverine-Confidence: 1
X Wolverine-Confidence: 0.53
7.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which of the following regex statements will match and return any price of the form $3.45 or $23.32 or $400 found in the string ‘x’?
re.findall('\$\d+\.\d{2}', x)
re.findall('$\d+(?:\.\d{2})?', x)
re.findall('\$\D+(\.\D{2})?', x)
re.findall('\$\d+\.?\d{0,2}', x)
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?