100% found this document useful (3 votes)
7K views5 pages

Week Quiz - 2 - Coursera

1. This document contains a 10 question quiz about regular expressions. 2. The questions cover topics like what regular expressions are, common symbols used like *, +, ?, and their meanings, and examples of regular expressions and the matches they would produce. 3. The quiz is part of a Coursera course on learning Python for network data to help students learn about extracting and parsing text data using regular expressions.

Uploaded by

Shaamim U Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
7K views5 pages

Week Quiz - 2 - Coursera

1. This document contains a 10 question quiz about regular expressions. 2. The questions cover topics like what regular expressions are, common symbols used like *, +, ?, and their meanings, and examples of regular expressions and the matches they would produce. 3. The quiz is part of a Coursera course on learning Python for network data to help students learn about extracting and parsing text data using regular expressions.

Uploaded by

Shaamim U Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1/23/2016

Quiz:RegularExpressions|Coursera

Quiz: Regular Expressions


10questions

1.
Which of the following best describes "Regular Expressions"?
The way Python handles and recovers from errors that would
otherwise cause a traceback
A small programming language unto itself
A way to calculate mathematical values paying attention to
operator precedence
A way to solve Algebra formulas for the unknown value

2.
What will the '\$' regular expression match?
The beginning of a line
An empty line
A dollar sign
The end of a line
A new line at the end of a line

3.
What would the following mean in a regular expression? [a-z0-9]
https://www.coursera.org/learn/pythonnetworkdata/exam/BENWm/quizregularexpressions

1/5

1/23/2016

Quiz:RegularExpressions|Coursera

Match anything but a lowercase letter or digit


Match any text that is surrounded by square braces
Match an entire line as long as it is lowercase letters or digits
Match a lowercase letter or a digit
Match any number of lowercase letters followed by any number
of digits

4.
What is the type of the return value of the re.findall() method?
A string
An integer
A single character
A boolean
A list of strings

5.
What is the "wild card" character in a regular expression (i.e., the
character that matches any character)?
$
?
*
+
^
.
https://www.coursera.org/learn/pythonnetworkdata/exam/BENWm/quizregularexpressions

2/5

1/23/2016

Quiz:RegularExpressions|Coursera

6.
What is the difference between the "+" and "*" character in regular
expressions?
The "+" matches at least one character and the "*" matches
zero or more characters
The "+" matches upper case characters and the "*" matches
lowercase characters
The "+" matches the beginning of a line and the "*" matches the
end of a line
The "+" matches the actual plus character and the "*" matches
any character
The "+" indicates "start of extraction" and the "*" indicates the
"end of extraction"

7.
What does the "[0-9]+" match in a regular expression?
Any number of digits at the beginning of a line
One or more digits
Zero or more digits
Any mathematical expression
Several digits followed by a plus sign

8.
What does the following Python sequence print out?

https://www.coursera.org/learn/pythonnetworkdata/exam/BENWm/quizregularexpressions

3/5

1/23/2016

Quiz:RegularExpressions|Coursera

x='From:Usingthe:character'
y=re.findall('^F.+:',x)
printy

:
From:
['From:']
['From: Using the :']
^F.+:

9.
What character do you add to the "+" or "*" to indicate that the match is
to be done in a non-greedy manner?
?
\g
$
**
^
++

10.
Given the following line of text:
[email protected]:14:162008

What would the regular expression '\S+?@\S+' match?

https://www.coursera.org/learn/pythonnetworkdata/exam/BENWm/quizregularexpressions

4/5

1/23/2016

Quiz:RegularExpressions|Coursera

[email protected]
From
\@\
marquard@uct
d@u

Submit Quiz

https://www.coursera.org/learn/pythonnetworkdata/exam/BENWm/quizregularexpressions

5/5

You might also like