Description:
During this lab, I needed to understand functions in Python. I was required to define a function in code while also being able to have multiple variables defined.
Code:
This is the sample 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): after = balance - payment newbill = add_monthly_interest(after) print "You still owe ", newbill return newbill bill = make_payment(bill / 2, bill) bill = make_payment(100,bill)
Screenshot:
This is the screenshot of the sample code.