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.
- In the original string
s = “the Truth”, the first letter is‘t’. capitalize()changes‘t’to‘T’.- It also changes the existing uppercase
‘T’in "Truth" to a lowercase‘t’. - Therefore, the final output is
“The truth”
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
