Explore topic-wise MCQs in Python.

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

1.

The special character B matches the empty string, but only when it is _____________

A. at the beginning or end of a word
B. not at the beginning or end of a word
C. at the beginning of the word
D. at the end of the word
Answer» C. at the beginning of the word
2.

The function of re.match is ____________

A. Error
B. Matches a pattern anywhere in the string
C. Matches a pattern at the end of the string
D. Matches a pattern at the start of the string
Answer» E.
3.

Which of the following pattern matching modifiers permits whitespace and comments inside the regular expression?

A. re.L
B. re.S
C. re.U
D. re.X
Answer» E.
4.

The function of re.search is __________

A. Matches a pattern at the start of the string
B. Matches a pattern at the end of the string
C. Matches a pattern from any part of a string
D. Such a function does not exist
Answer» D. Such a function does not exist