What will be the output of the following Python code?print("code. TANTRA".capitalize())OptionsCODE. TANTRAcode. tantraCode. tantraAbc. Def
Question
What will be the output of the following Python code?
print("code. TANTRA".capitalize())
Options:
- CODE. TANTRA
- code. tantra
- Code. tantra
- Abc. Def
Solution
The output of the Python code print("code. TANTRA".capitalize())
will be Code. tantra
.
Here's the step by step explanation:
-
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 letters. -
In the given code, the string is "code. TANTRA".
-
When the
capitalize()
function is applied to this string, the first character 'c' becomes 'C', and all other characters become lowercase, resulting in "Code. tantra".
So, the correct option is Code. tantra
.
Similar Questions
lect the correct answerWhat will be the output of the following Python code?print("code TANTRA".capitalize())
ect 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 will be the output of the following Python code?print('10CODETantra##%%@'.lower())Optionstantracodecodetantra10codetantra##%%@
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
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.