Skip to content

Instantly share code, notes, and snippets.

@daniloassis
Created October 15, 2013 20:22
Show Gist options
  • Save daniloassis/6998038 to your computer and use it in GitHub Desktop.
Save daniloassis/6998038 to your computer and use it in GitHub Desktop.
just a codecademy exercise that I'm using to teach my brother how to program :)
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):
# In make_payment, you should first subtract payment from balance
new_balance = balance - payment
# Then, call the function add_monthly_interest() with the new value.
new_balance = add_monthly_interest(new_balance)
# The return value you get from calling add_monthly_interest() should be returned
print "You still owe: %s" % new_balance
return new_balance
# To calculate how much we still owe, we will need to call make_payment twice.
# First, save the total hotel bill. (We already did that on line 4.)
# Next, call make_payment with bill as the balance and bill / 2 as the payment.
# Save this value as new_bill.
new_bill = make_payment(bill / 2, bill)
# Finally, call make_payment again with new_bill as the balance and 100 as the payment
make_payment(100, new_bill)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment