?
What will the following code output:
What will the following code output:
string = "Python"
print(string.lower())
print(string.lower())
Answer & Solution
Correct Answer:
Option
A
The correct answer is Option A: python
Here'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".
Here'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
Login to post a comment or share your explanation.
Login