Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Python function? re.findall("hello world", "hello", 1)
Q2
Choose the option wherein the two choices do not refer to the same option.
Q3
Which of the following statements regarding the output of the function re.match is incorrect?
Q4
What will be the output of the following Python code? import re s = 'abc123 xyz666 lmn-11 def77' re.sub(r'\b([a-z]+)(\d+)', r'\2\1:', s)
Q5
What will be the output of the following Python code? sentence = 'we are humans' matched = re.match(r'(.*) (.*?) (.*)', sentence) print(matched.group())
Q6
What will be the output of the following code: import re pattern = re.compile(r'b[A-Z]+b') result = pattern.findall('Hello, WORLD!') print(result)
Q7
In the functions re.search.start(group) and re.search.end(group), if the argument groups not specified, it defaults to . . . . . . . .
Q8
How can you replace a matched pattern with a new string using regular expressions in Python?
Q9
The difference between the functions re.sub and re.subn is that re.sub returns a . . . . . . . . whereas re.subn returns a . . . . . . . .
Q10
What will be the output of the following Python code? re.split('[a-c]', '0a3B6', re.I)
Q11
What will be the output of the following Python code? re.split(r'(n\d)=', 'n1=3.1, n2=5, n3=4.565')
-
A
-
B
-
C
-
D
Q12
What is a character class in regular expressions?
Q13
What will be the output of the following Python code? re.split(r'(a)(t)', 'Maths is a difficult subject')
Q14
What will be the output of the following Python code? re.split('mum', 'mumbai*', 1)
Q15
How can you specify a range of characters in a character class in regular expressions?
Q16
How can you match zero or more occurrences of a pattern in regular expressions?
Q17
What is the purpose of the re.MULTILINE flag in Python?
Q18
What will be the output of the following Python code? n = re.sub(r'\w+', 'Hello', 'Cats and dogs')
Q19
Which of the following functions does not accept any argument?
Q20
Which of the following functions returns a dictionary mapping group names to group numbers?
Q21
What is the output of the following code: import re result = re.sub(r's', '-', 'This is a test.') print(result)
Q22
The special character B matches the empty string, but only when it is . . . . . . . .
Q23
Which of the following pattern matching modifiers permits whitespace and comments inside the regular expression?
Q24
What will be the output of the following code: import re result = re.findall(r'd{1,3}', 'There are 25 apples and 300 oranges.') print(result)
Q25
What is the purpose of the re.sub() function in Python?