Single Choice Not Set

QWhat will be the output after the following statements?
txt = "For only {price:.2f} dollars!"
print(txt.format(price = 85))

ID: #3651 String Formatting in Python 293 views
Question Info
#3651Q ID
Not SetDifficulty
String Formatting in PythonTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A For only 85.00 dollars!
  • B For only 85.0 dollars!
  • C For only 85.01 dollars!
  • D For only 87.00 dollars!
Correct Answer

Explanation

  • The format() method formats the specified value(s) and insert them inside the string's placeholder.
  • The placeholder is defined using curly brackets: {}. Read more about the placeholders.
  • The format() method returns the formatted string.

Share This Question

Challenge a friend or share with your study group.