Lab 5: Taking a Vacation

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.

Screen Shot 2013-12-06 at 3.53.03 PMScreen Shot 2013-12-06 at 3.53.11 PM

Leave a Reply

Your email address will not be published. Required fields are marked *