Lab description: This lab showed how to use function in a advanced way. That way you can create functions to print out the hotel cost and what you still owe.
Source code:
def hotel_cost(nights):
return nights * 140
bill = hotel_cost(5)
def add_monthly_interest(balance):
return balance * (1 + (0.15 / 12))
def make_payment(payment, balance):
x = add_monthly_interest(balance – payment)
print “You still owe: %s” % x
return x
new_bill = make_payment(bill / 2, bill)
print make_payment(100, new_bill)