Taking A vacation
Description:
In this project, I defined various functions in order to then use them to calculate how much money was spent on this vacation.
Code: def hotel_cost(night):return night * 140
def plane_ride_cost(city):
if city == “Charlotte”:
return 183
if city == “Tampa”:
return 220
if city == “Pittsburgh”:
return 222
if city == “Los Angeles”:
return 475
def rental_car_cost(days):
if days >= 0 and days < 3:
return days * 40
elif days >= 3 and days < 7:
return days * 40 – 20
elif days >= 7:
return days * 40 – 50
def trip_cost(city, days, spending_money):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money
print trip_cost(“Los Angeles”, 5, 600)
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):
x = balance – payment
return add_monthly_interest(x)
print “You still owe: ” + str(x)
new_bill = make_payment(bill / 2, bill)
new_bill = make_payment(100, new_bill)
print new_bill