81. What will be the output of the following Python code?
re.sub('Y', 'X', 'AAAAAA', count=2)
re.sub('Y', 'X', 'AAAAAA', count=2)
82. What will be the output of the following Python code?
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')
matched = re.search(regex, sentence)
print(matched.group(2))
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')
matched = re.search(regex, sentence)
print(matched.group(2))
83. What will be the output of the following Python code?
sentence = 'we are humans'
matched = re.match(r'(.*) (.*?) (.*)', sentence)
print(matched.group(2))
sentence = 'we are humans'
matched = re.match(r'(.*) (.*?) (.*)', sentence)
print(matched.group(2))
84. Which of the following lines of code will not show a match?
85. The output of the following two Python codes are the same.
CODE 1
>>> re.split(r'(a)(t)', 'The night sky')
CODE 2
>>> re.split(r'\s+', 'The night sky')
CODE 1
>>> re.split(r'(a)(t)', 'The night sky')
CODE 2
>>> re.split(r'\s+', 'The night sky')
86. The character Dot (that is, '.') in the default mode, matches any character other than . . . . . . . .
87. What will be the output of the following Python code?
re.sub('morning', 'evening', 'good morning')
re.sub('morning', 'evening', 'good morning')
88. What will be the output of the following Python code?
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')
matched = re.search(regex, sentence)
print(matched.groups())
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')
matched = re.search(regex, sentence)
print(matched.groups())
89. Choose the function whose output can be: <_sre.SRE_Match object; span=(4, 8), match='aaaa'>.
90. What will be the output of the following Python code?
w = re.compile('[A-Za-z]+')
w.findall('It will rain today')
w = re.compile('[A-Za-z]+')
w.findall('It will rain today')