What is the output of the following code? print(“Python”.upper())

What is the output of the following code? print(“Python”.upper())

a) python
b) PYTHON
c) Python
d) pYTHON

Answer:

b) PYTHON

Explanation:

The .upper() method in Python converts all the characters in a string to uppercase. When applied to the string "Python", it returns "PYTHON".

result = "Python".upper()
print(result)  # Prints "PYTHON"

String methods like .upper() are commonly used in text processing tasks where case conversion is needed, such as normalizing input data or preparing text for case-insensitive comparisons.

Understanding and using string methods like .upper() is important for manipulating and formatting text in Python.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top