Single Choice
Not Set
QWhat will be the output after the following statements?
x = 'Python %.1f or Python %.2f' %(2.7, 3.51)
print(x)
ID: #3608
String Formatting in Python
414 views
Question Info
#3608Q ID
Not SetDifficulty
String Formatting in PythonTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
Let's evaluate the code:
%.1ffor the first placeholder:2.7formatted with one digit after the decimal point is2.7.%.2ffor the second placeholder:3.51formatted with two digits after the decimal point is3.51.
So, the output of the code will be:
Python 2.7 or Python 3.51
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic