Jul-03-2017, 11:18 AM
(This post was last modified: Jul-03-2017, 11:48 AM by ichabod801.)
my question here
I am new python user as i have embark to do programming, i have a task to complete but i having some challenges.
I have been asked to create four functions, Hotel Cost,Plane Cost, Car Rental and Holiday Cost
Please advise and assist as its also my first time to post i might made some mistake along.
Thanks
1 |
my code here |
I have been asked to create four functions, Hotel Cost,Plane Cost, Car Rental and Holiday Cost
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#The first function is - Hotel cost and as to take number of nights as an argument. def hotel_cost(number_of_nights): return ( 450 * (number_of_nights)) # The second function is - Plane Cost and as to take city as an argument and return cost of flight. use if/else if statement in the function to retrieve a price base on chosen city. def plane_cost(city): if city = = "Joburg" : return ( 1500 ) elif city = = "Cape Town" : return ( 1800 ) elif city = = "Jozi" : return ( 1200 ) else : return ( 0 ) #The third function is Car rental and as to take days as an argument. def car_rental(days): return ( 250 * (days)) #The last function is Holiday cost and as to take three arguments, number of nights,city,days, and return total cost of your holiday. def holiday_cost(number_of_nights,city,days): cost = (hotel_cost(number_of_nights) + plane_cost(city) + car_rental(days)) return ( "Total Holiday Cost:" + str (cost)) #and the last task to do on this project is to print the value of the holiday function to see the result, and thats where i am getting lost. i have trying this code print holiday_cost |
Thanks