I can't understand this plz help me


#1

meal = 44.50
tax = 6.75 / 100
tip = 15.0 / 100

meal = meal + meal * tax
total = meal + meal * tip

print("%.2f" % total) << I can’t understand this what is 2f and where is%??

Can anybody help me to understand this?


#2

%s is a placeholder for string variable, for example:

name = "gogopowerranger"
print "hello %s" % name

the % after the string is simply part of syntax to indicate that we are now going to provide the variable for the placeholder(s)

%f is a placeholder for a float number, .2 indicate the number of decimals


#3

thank you very much ^^


#4

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