What will be the output of the following Python code?
re.sub('Y', 'X', 'AAAAAA', count=2)Select an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
90
Questions
5/5
Page
Pick an option on a question to see the right answer and solution.
re.sub('Y', 'X', 'AAAAAA', count=2)Select an option to see the answer and solution.
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))Select an option to see the answer and solution.
sentence = 'we are humans'
matched = re.match(r'(.*) (.*?) (.*)', sentence)
print(matched.group(2))Select an option to see the answer and solution.
Select an option to see the answer and solution.
CODE 1
>>> re.split(r'(a)(t)', 'The night sky')
CODE 2
>>> re.split(r'\s+', 'The night sky')Select an option to see the answer and solution.
Select an option to see the answer and solution.
re.sub('morning', 'evening', 'good morning')Select an option to see the answer and solution.
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')
matched = re.search(regex, sentence)
print(matched.groups())Select an option to see the answer and solution.
Select an option to see the answer and solution.
w = re.compile('[A-Za-z]+')
w.findall('It will rain today')Select an option to see the answer and solution.