Test Index

Python Revision Tour Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 2 of 102
Marks: +1, -0
Identify the output of the following code snippet :
s = "the Truth"
print(s.capitalize())
[CBSE 2026 Set 4]
Solution:  
Concept:
str.capitalize() returns a copy of the string in which the first character is converted to uppercase and all other characters are converted to lowercase.
Explanation:
'the Truth' → first character 't' becomes 'T'; the rest 'he Truth' becomes 'he truth'.
Output:
The truth
Key point: capitalize() also lowercases the 'T' of 'Truth'. 'The Truth' would be the output of title(), and 'THE TRUTH' of upper().
Answer:
Option A (The truth)
© examsnet.com
Advertisements
Go to Question: