def hotel_cost (days): """Calculates the total cost of the hotel stay""" days = input("Enter number of nights: ") cost = 140 total_cost =days * cost return total_cost def plane_ride_cost (city): """Calculates the total cost of the plane ride""" city = raw_input ("What city are you staying at?: ") 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): """Calculates the total cost of the rental car""" day = input ("How many days are you going to stay?: ") total_daily_cost = 40 * day if day >= 7: return total_daily_cost - 50 elif day >= 3 and day <=6: return total_daily_cost - 20 else: print total_daily_cost def trip_cost (city,days): """Calculates the total cost of the trip summing hotel, plane, & rental costs""" return hotel_cost (days) + plane_ride_cost (city) + rental_car_cost (days) print trip_cost (1,1)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question