First, let me say I have done thorough research trying to understand. But I do not understand the explanations that others have given (which is understood by those who asked the question). This is the code I have problems with:
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)
When I delete the first "return bill" and run it, I get the first number but there is an error when it tries to calculate the second number. The def tax(bill) takes 100 and outputs 108 right? So if I delete the first "return bill", then why is def tip(bill) not doing it's calculations with 108 instead of giving an error?
I really have a problem with grasping the most basic concepts of programming. I've been learning intensely for 3 months now and this is where I am. It is a very slippery subject for my mind to grasp and I would really appreciate some help.