What will be the output of the following Python code?
print("abc. DEF".capitalize())
print("abc. DEF".capitalize())A. Abc. def
B. abc. def
C. Abc. Def
D. ABC. DEF
Answer: Option A
Solution (By Examveda Team)
The `capitalize()` method in Python converts the first character of a string to uppercase and the rest of the characters to lowercase.Given Code: `print("abc. DEF".capitalize())`
1. The first character `a` is converted to uppercase, resulting in `A`.
2. All other characters, including the uppercase `DEF`, are converted to lowercase, resulting in `bc. def`.
Final Output: `Abc. def`
Join The Discussion
Comments (1)
Related Questions on Introduction to Python
What is Python primarily used for?
A. Web browsing
B. Data analysis
C. Video editing
D. Game development
Who developed Python Programming Language?
A. Wick van Rossum
B. Rasmus Lerdorf
C. Guido van Rossum
D. Niene Stom
Which of the following is an advantage of Python?
A. It compiles to machine code
B. It enforces strict typing
C. It has a large standard library
D. It requires extensive memory management
What is the role of the Python interpreter?
A. To convert Python code to assembly language
B. To manage memory allocation
C. To execute Python code line by line
D. To compile Python code into bytecode

Explanation:
The capitalize() method in Python performs the following:
Converts the first character of the string to uppercase (if it is a letter).
Converts all other characters in the string to lowercase.
So, "abc. DEF".capitalize() processes the string as:
The first character 'a' is converted to uppercase: 'A'.
All other characters are converted to lowercase: 'bc. def'.
Output:
Abc. def