1. What is the Python module for regular expressions? A. regex B. pyregex C. re
ID: 3733861 • Letter: 1
Question
1. What is the Python module for regular expressions? A. regex B. pyregex C. re D. pyre
2.
What is the output of the code shown below?
re.split(r'(a)(t)', 'Maths is a difficult subject')
['M a t h s i s a d i f f i c u l t s u b j e c t']
['Maths is a difficult subject']
['Maths', 'is', 'a', 'difficult', 'subject']
['M', 'a', 't', 'hs is a difficult subject']
3.
Which of the following creates a pattern object?
re.create(str)
re.regex(str)
re.compile(str)
re.assemble(str)
A.['M a t h s i s a d i f f i c u l t s u b j e c t']
B.['Maths is a difficult subject']
C.['Maths', 'is', 'a', 'difficult', 'subject']
D.['M', 'a', 't', 'hs is a difficult subject']
3.
Which of the following creates a pattern object?
A.re.create(str)
B.re.regex(str)
C.re.compile(str)
D.re.assemble(str)
Explanation / Answer
1)Answer is C.re module in python is used for regular expressions.
2)Answer is D.output is ['M','a','t','hs is a difficult subject'].First arguement to re.split is pattern.according to that pattern it splits the given string.
3)Answer is C.re.compile creates the pattern object from given string.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.