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))Optionstanone of the mentionederrorcodetantra
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(7), '*', sep='')Options* codetantra ** codetantra**codetantra ** codetantra *
What will be the output of the following Python code?ct = "codetantra"while j in ct: print(j, end=" ")Optionsc o d e t a n t r aj j j j j j j j j j …errorcodetantra
What will be the output of the following Python code?>>>ct1="codetantra">>>ct1[:3]>>>Optionscododetacodetantrade
What will be the output of the following Python code snippet?print('codetantra'.replace('ea', '90'))Optionscodetantracod9t0ntracod90tantracod9tantr0
elect the correct answerWhat will be the output of the following Python code?c="codetantra"def t(n): print(n)+ca=t("coding")print(a)Optionscodingerrorcodetantraerrorerrorbitterbutter
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.