Need Help!


#1

def tax(bill):
****bill *= 1.08
****print "With tax: %f" % bill
****return bill

Can anyone explain the use of the 2 "%" in line 3?


#2

@fsy135215,
google search
print "%f" site:python.org
https://docs.python.org/2.4/lib/typesseq-strings.html


#3

Hi @fsy135215,

%f serves as a placeholder: with the % in (%bill) you tell python what should be 'placed' at the position of the placeholder. In this case the value of bill will be placed at the position of %f in the printed information.

I hope that helps...

Cheers


#4

@khoel,
AND it would displayed as a floating-point......