My Report

Python Regular Expression Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following Python code?

re.sub('morning', 'evening', 'good morning')

2. The function re.error raises an exception if a particular string contains no match for the given pattern.

3. What will be the output of the following Python code?

re.split('[a-c]', '0a3B6', re.I)

4. Choose the option wherein the two choices do not refer to the same option.

5. What will be the output of the following Python code?

re.compile('hello', re.X)

6. What will be the output of the following Python code?

re.escape('new**world')

7. What will be the output of the following Python code?

re.findall('good', 'good is good')
re.findall('good', 'bad is good')

8. The difference between the functions re.sub and re.subn is that re.sub returns a _______________ whereas re.subn returns a __________________

9. What will be the output of the following Python code?

re.split('mum', 'mumbai*', 1)

10. What will be the output of the following Python code?

re.fullmatch('hello', 'hello world')

 

Start practicing “1000 MCQs on Python”, and once you are ready, you can take tests on all topics by attempting our “Python Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.