Explore topic-wise InterviewSolutions in .

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

51.

The character Dot (that is, ‘.’) in the default mode, matches any character other than _____________(a) caret(b) ampersand(c) percentage symbol(d) newlineThe question was asked at a job interview.Enquiry is from Regular Expressions topic in portion Regular Expressions and Files of Python

Answer»

The correct choice is (d) newline

Easiest EXPLANATION - The CHARACTER Dot (that is, ‘,’) in the default mode, MATCHES any character other than newline. If DOTALL flag is USED, then it matches any character other than newline.

52.

What does the function re.search do?(a) matches a pattern at the start of the string(b) matches a pattern at any position in the string(c) such a function does not exist(d) none of the mentionedI had been asked this question in class test.The above asked question is from Regular Expressions in division Regular Expressions and Files of Python

Answer»

Correct choice is (B) MATCHES a PATTERN at any position in the string

For explanation: It will LOOK for the pattern at any position in the string.

53.

What does the function re.match do?(a) matches a pattern at the start of the string(b) matches a pattern at any position in the string(c) such a function does not exist(d) none of the mentionedI have been asked this question in class test.The origin of the question is Regular Expressions in division Regular Expressions and Files of Python

Answer»

The correct option is (a) MATCHES a pattern at the start of the string

To explain I WOULD say: It will look for the pattern at the BEGINNING and return NONE if it isn’t found.

54.

Which of the following creates a pattern object?(a) re.create(str)(b) re.regex(str)(c) re.compile(str)(d) re.assemble(str)The question was posed to me in homework.My doubt stems from Regular Expressions in chapter Regular Expressions and Files of Python

Answer»

Right answer is (C) re.compile(STR)

To EXPLAIN: It converts a given STRING into a pattern OBJECT.

55.

Which module in Python supports regular expressions?(a) re(b) regex(c) pyregex(d) none of the mentionedI got this question during an interview for a job.The above asked question is from Regular Expressions in section Regular Expressions and Files of Python

Answer»

Correct CHOICE is (a) re

The EXPLANATION is: re is a PART of the STANDARD LIBRARY and can be imported using: import re.