हिंदी

Identify the output of the following code snippet: 8 = “the Truth” print(s.capitalize()) - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

Identify the output of the following code snippet:

8 = “the Truth”

print(s.capitalize())

विकल्प

  • The truth

  • THE TRUTH

  • The Truth

  • the Truth

MCQ
Advertisements

उत्तर

The truth

Explanation:

The capitalize() A method in Python transforms a string by making the very first character uppercase and converting all other characters to lowercase.

  1. In the original string s = “the Truth”, the first letter is ‘t’.
  2. capitalize() changes ‘t’ to ‘T’.
  3. It also changes the existing uppercase ‘T’ in "Truth" to a lowercase ‘t’.
  4. Therefore, the final output is “The truth”
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2025-2026 (March) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×