Question 1 of 25
Hints left: 3
Q1
The output of the following two Python codes are the same. CODE 1 >>> re.split(r'(a)(t)', 'The night sky') CODE 2 >>> re.split(r'\s+', 'The night sky')
Q2
The function of re.match is . . . . . . . .
Q3
How can you match the end of a string using regular expressions?
Q4
What will be the output of the following Python code? s = 'welcome home' m = re.match(r'(.*)(.*?)', s) print(m.group())
Q5
What will be the output of the following Python code? re.sub('Y', 'X', 'AAAAAA', count=2)
Q6
The output of the following two Python codes are the same. p = re.compile('hello') r = p.match('hello everyone') print(r.group(0)) r = re.match('hello', 'hello everyone') print(r.group(0))
Q7
What will be the output of the following Python code? sentence = 'we are humans' matched = re.match(r'(.*) (.*?) (.*)', sentence) print(matched.group(2))
Q8
Which of the following special characters represents a comment (that is, the contents of the parenthesis are simply ignores)?
Q9
What is the purpose of the re.search() function in Python?
Q10
What will be the output of the following Python code? re.fullmatch('hello', 'hello world')
Q11
What will be the output of the following Python code? import re s = "A new day" m = re.match(r'(.*)(.*?)', s) print(m.group(2)) print(m.group(0))
Q12
The character Dot (that is, '.') in the default mode, matches any character other than . . . . . . . .
Q13
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.group(2))
Q14
What will be the output of the following Python code? a = re.compile('0-9') a.findall('3 trees')
Q15
Which of the following functions creates a Python object?
Q16
What will be the output of the following Python code? a=re.compile('[0-9]+') a.findall('7 apples and 3 mangoes')
Q17
How can you match either of two patterns in regular expressions using the | operator?
Q18
What is the output of the following code: import re pattern = re.compile(r'(d+)s(w+)') result = pattern.findall('There are 5 apples and 3 oranges.') print(result)
Q19
What will be the output of the following Python code? sentence = 'we are humans' matched = re.match(r'(.*) (.*?) (.*)', sentence) print(matched.groups())
Q20
Which of the following lines of code will not show a match?
Q21
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.groups())
Q22
What will be the output of the following Python code? re.findall('good', 'good is good') re.findall('good', 'bad is good')
Q23
What will be the output of the following Python code? re.sub('morning', 'evening', 'good morning')
Q24
Which of the following special characters matches a pattern only at the end of the string?
Q25
The following Python code snippet results in an error. c=re.compile(r'(\d+)(\[A-Z]+)([a-z]+)') c.groupindex