Explore topic-wise MCQs in Python.

This section includes 6 Mcqs, each offering curated multiple-choice questions to sharpen your Python knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of the following functions results in case insensitive matching?

A. re.A
B. re.U
C. re.I
D. re.X
Answer» D. re.X
2.

Which of the following functions clears the regular expression cache?

A. re.sub()
B. re.pos()
C. re.purge()
D. re.subn()
Answer» D. re.subn()
3.

Choose the function whose output can be: <_sre.SRE_Match object; span=(4, 8), match=’aaaa’>.

A. >>> re.search(‘aaaa’, “alohaaaa”, 0)
B. >>> re.match(‘aaaa’, “alohaaaa”, 0)
C. >>> re.match(‘aaa’, “alohaaa”, 0)
D. >>> re.search(‘aaa’, “alohaaa”, 0)
Answer» B. >>> re.match(‘aaaa’, “alohaaaa”, 0)
4.

________ matches the start of the string. ________ matches the end of the string.

A. ‘^’, ‘$’
B. ‘$’, ‘^’
C. ‘$’, ‘?’
D. ‘?’, ‘^’
Answer» B. ‘$’, ‘^’
5.

The expression a{5} will match _____________ characters with the previous regular expression.

A. 5 or less
B. exactly 5
C. 5 or more
D. exactly 4
Answer» C. 5 or more
6.

The character Dot (that is, ‘.’) in the default mode, matches any character other than _____________

A. caret
B. ampersand
C. percentage symbol
D. newline
Answer» E.