CBSE Class 11 Computer Science Question 2 of 19

Strings in Python — Question 12

Back to all questions
12
Question

Question 12

What will be the output of the following code?

A = 'Virtual Reality'
A.replace('Virtual', 'Augmented')
  1. Virtual Augmented
  2. Reality Augmented
  3. Augmented Virtual
  4. Augmented Reality
Answer

Augmented Reality

Reason — The replace() method creates and returns a new string with the specified substring replaced, without altering the original string. In this case, 'Virtual' is replaced by 'Augmented', resulting in 'Augmented Reality'.

Get the Bright Tutorials app Stuck on a question? Ask Bright Buddy — your AI tutor — for step-by-step help in the app.