Python Beginner


#1

what does print("%.2f" % total) mean?
As a beginner ,I just want to know the meaning of the code below,or someone kind to paste the link refer to these two statements! thanks in advance;

print("%.2f" % total)

I understand the first part which are inside quotation marks BUT I don’t get it why they put % between the first part and total?


#2

%f is placeholder for a float value (total in this case), just like %s if you want to insert variable into string

the confusing thing is the .2 which simple tells us we want two decimals


#3

Hi, Thanks for your quick response. I just wonder why they put % (the bold one) on this one print("%.2f" % total)


#4

the %f is the placeholder, then after the string you put a % to tell python that you are now going to supply the variables for the string, its just syntax


#5

Thanks to you, I got this one now. Ciao


#6