subject

PYTHON Program using Functions with Parameters Write a PYTHON program to calculate the total cost of a trip.

Steps:

Define a function called hotel_cost with one parameter no_of_nights . The hotel costs $140 per night. So, the function hotel_cost should return the total cost based on the number of nights.
Define a function called flight_cost with a parameter city. The function should return a different price depending on the location. Below are some sample destinations and their corresponding round-trip prices. You can add more cities to the list. If the input city is not in the list use $250 as the flight cost.
Charlotte - $183 ,Tampa - $220, Pittsburgh - $222, Los Angeles - $475

3. Define a function called rental_car_cost with a parameter called days. Calculate the cost of renting the car: Every day you rent the car costs $40.(cost=40*days) if you rent the car for 7 or more days, you get $50 off your total(cost-=50). Alternatively, if you rent the car for 3 or more days, you get $20 off your total. You cannot get both of the above discounts. Return that cost.

4. Then, define a function called Total_Trip_Cost that takes cities and days(Number of days is a required argument and the cities to visit is an arbitrary tuple *args). Calculate the total trip cost for each given city for the number of days by adding the values returned by the functions rental_car_cost, hotel_cost, and flight_cost.

5. Finally, ask for user input for the number of days for the trip and the list of cities and print the total cost of the trip for each city for the given number of days.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:00
Give an example of a case where a two-way handshake to establish a connection could leave one side of the connection live while the other side does not believe there is a connection.
Answers: 1
question
Computers and Technology, 23.06.2019 13:00
Which of the following statements is false? a. a class can directly inherit from class object. b. if the class you're inheriting from declares instance variables as private, the inherited class can access those instance variables directly. c. a class's instance variables are normally declared private to enforce good software engineering. d. it's often much more efficient to create a class by inheriting from a similar class than to create the class by writing every line of code the new class requires.
Answers: 3
question
Computers and Technology, 23.06.2019 20:00
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
Perform an online search about the booting process of a computer and list all the steps
Answers: 2
You know the right answer?
PYTHON Program using Functions with Parameters Write a PYTHON program to calculate the total cost o...
Questions
question
Mathematics, 20.09.2020 22:01
question
Biology, 20.09.2020 22:01
Questions on the website: 13722361