Python: A question in exercise 5. Total, in Tip Calculator related to % in the print statement


This is the link of the exercise i have been performing.

There is no error message, i have a question regarding the below code

print("%.2f" % total)

In the above code "%.2f" is used to show 2 digits after the point.
here f is float data type??

And why have we use % total, total is to print the total but what is the use of %??



"%f" % total

we can use %f as placeholder in a string, then at the end of the string, we add a % (this is just syntax) to let python know we are going supply variable for which we added placeholders inside the string


i didn't get u...
can u elaborate?plz


can you elaborate on what you don't understand?


Problem solved brother, thank you for ur help.

stetim94 Codecademy Moderator
March 3

can you elaborate on what you don't understand?

Visit Topic or reply to this email to respond.

In Reply To



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.