What will the following code output:
string = "Python"
print(string.lower())
print(string.lower())
A. python
B. PYTHON
C. pyThon
D. PyThOn
Answer: Option A
Solution (By Examveda Team)
The correct answer is Option A: pythonHere's why:
The code uses the .lower() method on a string.
The .lower() method is a built-in function in Python for strings.
Its purpose is to convert all uppercase characters in a string to lowercase.
In the given code, the string is "Python".
When string.lower() is executed, it converts the 'P' to 'p'.
All other characters are already in lowercase, so they remain unchanged.
Therefore, the output is "python".
Join The Discussion
Comments (1)
Related Questions on Strings in Python
Which of the following is the correct way to create a string in Python?
A. "Hello, World!"
B. 'Hello, World!'
C. "Hello, World!'
D. 'Hello, World!"
What does the len() function do when applied to a string?
A. Returns the length of the string
B. Converts the string to lowercase
C. Converts the string to uppercase
D. Removes leading whitespace
Which character is used to access individual elements of a string by index in Python?
A. . (period)
B. , (comma)
C. : (colon)
D. [ and ] (square brackets)
Answer is A