What is this syntax?


What is bill *
Should it not be bill

def tax(bill):
    """Adds 8% tax to a restaurant bill."""
    bill *= 1.08
    print "With tax: %f" % bill
    return bill

def tip(bill):
    """Adds 15% tip to a restaurant bill."""
    bill *= 1.15
    print "With tip: %f" % bill
    return bill
meal_cost = 100
meal_with_tax = tax(meal_cost)
meal_with_tip = tip(meal_with_tax)


Also, when formatting with strings using %, does it matter if you use %d or any other letter instead of %f.
Also, why is %f not % to coincide with % (bill). What is the significance of the f in %f ?


%f is most certainly important, it indicate float numbers. You can read about it here


Oh, so the letter indicates the type of the data. Thank you!!!!!!



What is bill *

Should it not be bill


yes it does

i don't see what you are referring to.


On line 3 it says

bill *= 1.08

What does *= mean?

Thank you.


i can't conclude from bill * that you mean bill *= 1.08. It is a nice little shorthand, this is without shorthand:

bill = bill * 1.08

you basically update (re-assign) the current stored value multiplied by 1.08, in the same variable name. Really useful.