हिंदी

Identify the output of the following code snippet: text = "PYTHONPROGRAM" text=text.replace('PY','#') print(text) - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

Identify the output of the following code snippet:

text = "PYTHONPROGRAM"
text=text.replace('PY','#')
print(text)

विकल्प

  • #THONPROGRAM

  • ##THON#ROGRAM

  • #THON#ROGRAM

  • #YTHON#ROGRAM 

MCQ

उत्तर

#THONPROGRAM

Explanation:

The replace() function replaces all occurrences of the given substring. Here, 'PY' is replaced with '#'. Only at the beginning of the original string "PYTHONPROGRAM" does the substring 'PY' appear.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2024-2025 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×