What does % mean in terms of function in coding


#1



print("%.2f" % total) what does this mean? regards with tip calculator program


print("%.2f" % total) what does this mean? regards with tip calculator program

why did not use print (total)


#2

The % operator in the above expression denotes a formatting directive. It is essentially telling Python to use two decimal places in the print formatting of the value total which is denoted as a float. The output is a string, but the total is unchanged, only copied and converted for output.


#3

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