1.

Choose the function whose output can be: .(a) >>> re.search(‘aaaa’, “alohaaaa”, 0)(b) >>> re.match(‘aaaa’, “alohaaaa”, 0)(c) >>> re.match(‘aaa’, “alohaaa”, 0)(d) >>> re.search(‘aaa’, “alohaaa”, 0)The question was asked in an internship interview.This key question is from Regular Expressions topic in section Regular Expressions and Files of Python

Answer»

The correct option is (a) >>> re.SEARCH(‘aaaa’, “alohaaaa”, 0)

Explanation: The output shown above is that of a search function, whose pattern is ‘aaaa’ and the STRING is that of 8 characters. The only option which matches all these criteria is:

 >>> re.search(‘aaaa’, “alohaaaa”, 0)



Discussion

No Comment Found

Related InterviewSolutions