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