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_CLEARS_THE_REGULAR_EXPRESSION_CACHE??$

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

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» E.
3.

[“hello”]$

A. [ ]
B. hello
C. hello world
Answer» D.
4.

’]$

A. [‘Hello, ‘hello’, ‘hello’]
B. [‘Hello’, ‘hello’, ‘hello’, ‘.’]
C. [‘Hello’, ‘hello’, ‘hello’, ”]
Answer» C. [‚Äö√Ñ√∂‚àö√ë‚àö‚â§Hello‚Äö√Ñ√∂‚àö√ë‚àö¬•, ‚Äö√Ñ√∂‚àö√ë‚àö‚â§hello‚Äö√Ñ√∂‚àö√ë‚àö¬•, ‚Äö√Ñ√∂‚àö√ë‚àö‚â§hello‚Äö√Ñ√∂‚àö√ë‚àö¬•, ‚Äö√Ñ√∂‚àö√ë‚àöœÄ]
5.

________ matches the start of the string.

A.
B. ‘^’, ‘$’
C. ‘$’, ‘^’
Answer» B. ‚Äö√Ñ√∂‚àö√ë‚àö‚â§^‚Äö√Ñ√∂‚àö√ë‚àö¬•, ‚Äö√Ñ√∂‚àö√ë‚àö‚â§$‚Äö√Ñ√∂‚àö√ë‚àö¬•
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.