Lab 5: Taking a Vacation

lab 5 take a vacation

Description: In this lab we worked with functions and many types of them. But taking a vacation showed us how to do the math through python. We learned how to do the interest and the billing information. We also calculated the cities and how much it would cost to stay and how much spending money we would use at the city. At the end we did the final result and we got the balance and payment add up.

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):
return add_monthly_interest(balance-payment)

new_bill = make_payment(bill/2,bill)

print “You still owe:”
print make_payment(100,new_bill)

def distance_from_zero(n):
if type(n) == int:
return abs(n)
elif type(n) == float:
return abs(n)
else:
return “Not an integer or float!”
distance_from_zero(10)