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: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:00, yolo1430
Acetylene is a gas which burns rapidly on its own, and is considered highly explosive. a) true b) false
Answers: 2
image
Computers and Technology, 22.06.2019 21:50, IdkHowToDoMath
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
image
Computers and Technology, 23.06.2019 04:31, manlyman31
Selling a product through an electronic medium is
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, sophx
Apunishment or the threat of punishment used to enforce conformity. select the best answer from the choices provided t f
Answers: 1
You know the right answer?
PYTHON Program using Functions with Parameters Write a PYTHON program to calculate the total cost o...

Questions in other subjects:

Konu
History, 30.03.2020 02:04