Skip to content

Instantly share code, notes, and snippets.

@stevencombs
Created August 11, 2013 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencombs/6206891 to your computer and use it in GitHub Desktop.
Save stevencombs/6206891 to your computer and use it in GitHub Desktop.
# Number is Integer or Float - return Absolute Function
# A Codecademy Python (Make a Payment: Run It) assignment
# Dr. Steven B. Combs, coding novice
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):
payment = balance - payment
new_balance = add_monthly_interest(payment)
return "You still owe: " + str(new_balance)
print make_payment(100, 700) # Two values are passed to function make_payment
# 100 is the payment and 700 is the balance calculated from 5 nights at $140
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment