What will be the output of the following Python code?print("codetantra".center(0))Optionstanone of the mentionederrorcodetantra
Question
What will be the output of the following Python code?
print("codetantra".center(0))
Options:
- one of the mentioned
- error
- codetantra
Solution
The output of the Python code print("codetantra".center(0))
will be "codetantra".
The center()
method in Python is used to center align the string. It takes two arguments:
- width - length of the string with filled characters (default is space)
- fillchar (optional) - filling character
In this case, the width is given as 0, which means the string "codetantra" will not be padded with any additional characters and will be printed as it is. Therefore, the output will be "codetantra".
Similar Questions
What will be the output of the following Python code?print("codetantra".center(0))Optionsnone of the mentionedtacodetantraerror
What will be the output of the following Python code snippet?print('codetantra'.replace('ea', '90'))Optionscodetantracod9t0ntracod90tantracod9tantr0
What is the output of the code:print(['love', 'python'][bool('codetantra')])OptionslovecodetantraNonepython
What will be the output of the following Python code?print('10CODETantra##%%@'.lower())Optionstantracodecodetantra10codetantra##%%@
Select the correct answerWhat will be the output of the following Python function?print(len(["codetantra",12, 40, 16, "code", "tantra"]))Options6Error45
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.