Use of %


why % before total is used in print("%.2f" % total")


its python syntax, %f is a placeholder for a float number. just like %s is a string placeholder to insert variables into a string


i am asking about the % used before total


another part of python syntax, the % tells python we are now going to supply the variable we promised in the string.


is it like , used in c for differentiating a variable and a statement


Does it matter? Its part of the python syntax, if you want to know how its interpreted by the underlying C code, you will first have to learn C. I wouldn’t focus too much on this yet, to get to this point with computers that we currently are, have taken million of man hours

we are standing on the shoulder of giants, sometimes, certain things have to just be accepted, you can get into more depth later


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