| Snaprecruit.com

| Snaprecruit.com

Interview question based on skill :

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. What is the output of the code shown below? re.split('[a-c]', '0a3B6', re.I)

Correct Answer is : [‘0’, ‘3B6’]

2. What is the output of the code shown below? re.sub('morning', 'evening', 'good morning')

Correct Answer is : ‘good evening’

3. The function re.error raises an exception if a particular string contains no match for the given pattern. State whether true or false.

Correct Answer is : FALSE

4. The output of the code shown below: re.escape('new**world')

Correct Answer is : ‘new\\*\\*world’

5. What is the output of the code shown below? re.fullmatch('hello', 'hello world')

Correct Answer is : No output

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

Correct Answer is : re.L

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

Correct Answer is : string, tuple

8. The output of the code shown below is: re.split('mum', 'mumbai*', 1)

Correct Answer is : [”, ‘bai*’]

9. What is the output of the code shown below? re.findall('good', 'good is good') re.findall('good', 'bad is good')

Correct Answer is : [‘good’, ‘good’]

10. The output of the snippet of code shown below is: re.split(r'(n\d)=', 'n1=3.1, n2=5, n3=4.565')

Correct Answer is : [”, ‘n1’, ‘3.1, ‘, ‘n2’, ‘5, ‘, ‘n3’, ‘4.565’]

11. The function of re.search is:

Correct Answer is : Matches a pattern from any part of a string

12. Which of the following functions creates a Python object?

Correct Answer is : re.compile(str)

13. Which of the following pattern matching modifiers permits whitespace and comments inside the regular expression:

Correct Answer is : re.X

14. What is the output of the code shown below? s = 'welcome home' m = re.match(r'(.*)(.*?)', s) print(m.group())

Correct Answer is : welcome home

15. The function of re.match is:

Correct Answer is : Matches a pattern at the start of the string

16. The special character \B matches the empty string, but only when it is:

Correct Answer is : not at the beginning or end of a word

17. The output of the code shown below is: import re s = "A new day" m = re.match(r'(.*)(.*?)', s) print(m.group(2))   print(m.group(0))

Correct Answer is : No output

18. Which of the following special characters matches a pattern only at the end of the string?

Correct Answer is : \Z

19. The output of the two codes shown below is the same. State whether true or false. p = re.compile('hello') r = p.match('hello everyone') print(r.group(0))   r = re.match('hello', 'hello everyone') print(r.group(0))

Correct Answer is : TRUE

20. What is the output of the code shown? re.match('sp(.*)am', 'spam')

Correct Answer is : <_sre.SRE_Match object; span=(0, 4), match='spam'>