lect the correct answerWhat will be the output of the following Python code?print("code TANTRA".capitalize())
Question
Select the correct answer
What will be the output of the following Python code?
print("code TANTRA".capitalize())
Solution
The output of the Python code print("code TANTRA".capitalize())
will be Code tantra
.
The capitalize()
function in Python converts the first character of a string to a capital (uppercase) letter, while making all other characters in the string lowercase.
Here are the steps:
- The
capitalize()
function is called on the string"code TANTRA"
. - The first character of the string,
"c"
, is converted to uppercase, becoming"C"
. - All other characters in the string are converted to lowercase, so
"ODE TANTRA"
becomes"ode tantra"
. - The resulting string,
"Code tantra"
, is printed to the console.
Similar Questions
Select the correct answerWhat will be the output of the following Python code?print("abc. DEF".capitalize())OptionsAbc. Defabc. defAbc. defABC. DEF
rect answerWhat will be the output of the following Python code?>>>pythonclass = "code tantra">>>print("%s" % pythonclass[4:7])Optionstacotantrant
What is the output of the following program?c = ['code', 'tantra']for t in c: t.upper()print(c)Options['CODE' , 'TANTRA']TANTRA['code', 'tantra']CODE
Select the correct answerWhat will be the output of the following Python code?def ct(y): global y y+=2 print(y)ct(5)print("hi")Optionserror77hihi
What will be the output of the following Python code?print("codetantra".center(0))Optionsnone of the mentionedtacodetantraerror
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.