Question 1 of 25
Hints left: 3
Q1
What is the output of the following code: import re result = re.search(r'd{2}', 'There are 25 apples and 3 oranges.') print(result.group())
Q2
Which of the following will result in an error?
Q3
The expression a{5} will match . . . . . . . . characters with the previous regular expression.
Q4
What will be the output of the following Python code? import re re.ASCII
Q5
The function of re.search is . . . . . . . .
Q6
. . . . . . . . matches the start of the string. . . . . . . . . matches the end of the string.
Q7
What will be the output of the following Python code? re.match('sp(.*)am', 'spam')
Q8
What is the purpose of the re.VERBOSE flag in Python?
Q9
Which of the codes shown below results in a match?
Q10
Which of the following functions clears the regular expression cache?
Q11
What is the purpose of the re.findall() function in Python?
Q12
What will be the output of the following Python code? sentence = 'horses are fast' regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)') matched = re.search(regex, sentence) print(matched.groupdict())
Q13
What will be the output of the following Python code? re.escape('new**world')
Q14
What will be the output of the following Python code? re.split(r'\s+', 'Chrome is better than explorer', maxspilt=3)
-
A
-
B
-
C
-
D
Q15
What will be the output of the following Python code? re.subn('A', 'X', 'AAAAAA', count=4)
Q16
Which of the following functions results in case insensitive matching?
Q17
What will be the output of the following Python code? re.split('\W+', 'Hello, hello, hello.')
-
A
-
B
-
C
-
D
Q18
How can you extract a group from a matched regular expression in Python?
Q19
What is the output of the following code: import re result = re.search(r'hello', 'Hello, world!', re.IGNORECASE) print(result.group())
Q20
What will be the output of the following Python code? m = re.search('a', 'The blue umbrella') m.re.pattern
Q21
The function re.error raises an exception if a particular string contains no match for the given pattern.
Q22
How can you match the beginning of a string using regular expressions?
Q23
What will be the output of the following Python code? re.compile('hello', re.X)
Q24
What is the purpose of the re.DOTALL flag in Python?
Q25
What will be the output of the following code: import re pattern = re.compile(r'd+') result = pattern.search('There are 5 apples and 3 oranges.') print(result.group())