Vidyalelo
Python · Q52

Python Introduction and basic

Programming · Python · question 52

Q52

What will be the output of the following Python code? print("abc. DEF".capitalize())

A.
Abc. def
Answer
B.
abc. def
C.
Abc. Def
D.
ABC. DEF

Answer: Option A

Solution

Answer: Option A
Solution:
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`