Test Series - python

Test Number 93/108

Q: The function re.error raises an exception if a particular string contains no match for the given pattern.
A. True
B. False
C. none
D. ..
Solution: The function re.error raises an exception when a string passed to one of its functions here is not a valid regular expression. It does not raise an exception if a particular string does not contain a match for the given pattern.
Q: Choose the option wherein the two choices do not refer to the same option.
A.  re.I re.IGNORECASE
B.  re.M re.MULTILINE
C.  re.X re.VERBOSE
D.  re.L re.LOWERCASE
Solution: The function re.L is also written as re.LOCALE. There is no function such as re.LOWERCASE in the re module of Python.
Q: The difference between the functions re.sub and re.subn is that re.sub returns a _______________ whereas re.subn returns a __________________
A. string, list
B. list, tuple
C. string, tuple
D. tuple, list
Solution: The difference the functions re.sub and re.subn is that re.sub returns a string whereas re.subn returns a tuple.

You Have Score    /3