Question: Please USE PYTHON only to solve the following problem and be sure to follow all instructions carefully. Thank you. The following template is for your

Please USE PYTHON only to solve the following problem and be sure to follow all instructions carefully. Thank you.

Please USE PYTHON only to solve the following problem and be sure

The following template is for your reference:

to follow all instructions carefully. Thank you. The following template is for

We are calculating ticket prices for riding the metro. There are very specific rules and conditions that affect overall price; we first have a simpler version, and then a larger version (which can optionally re-use your simpler version if it helps). check_rush_ hour(day, hour, minute): Given what time it is, determines if the moment is during a rush hour or not. This answer is returned as a bool. We define rush hours as from 5:30am to 9:30am, and from 3:00pm to 7:00pm, on weekdays only (start time is part of rush hour, stop time is not). assume: day is a string like "Sunday", and will only be a valid day. hour is an int from 0 to 23 minute is an int from 0 to 59 check-rush-hour( "Monday", 6, check-rush-hour( "Tuesday", 16, check-rush-hour( "Wednesday", 9, check-rush-hour( "Friday", 5, check-rush-hour( "Saturday", 17, )-True 15) True 38) False 38) True ) False #during morning rush, 6:00am #during evening rush, 4:15pm #stop time not part of rush hour #during rush hour on a weekday #not a weekday, would have been otherwise simple_fare (num_stops):Given the number of stops, calculates the simple fare. Each stop adds some amount to the price: the first five stops add S1 each; the next 6 add 50f each; the next 8 stops add 25d each; any additional stops are free. Assume num_stops is a non-negative int. simple fare(1) 1 simple-fare(5) 5 simple-fare(6) 5.5 simple fare(11)8 simple-fare(12) 8.25 simple-fare(30) 10 # each stop cost $1 # first five stops were $1, next stop was only 50g #five @ $1, 6 @ 5e4 # five @ $1, # Lots of free stops; this is the maximum fare 6 @ ses, 1 @ 254 fare(num_ stops, age, is_rush_ hour, want return_fare, num_pets): Given how far to go, how old the passenger is, whether it's rush hour or not, whether they want to purchase a return fare at current prices, and how many pets they are bringing with them, calculate the full price according to the following rules: o o o o kids under age 5 ride any distance free each transported pet adds $1 per ride, regardless of distance or age or rush hour in rush hour, 0-10 stops costs $8 for the distance, all longer trips cost $12. outside of rush hour, pricing is the exact same as with simple_fare (it's quite possible to call that function and reuse its efforts!) o a return ticket may be purchased at the same time for the same price. (perhaps we could leave after o senior citizens (age 65+) pay half as much for the distance/pet choice, never paying more than S4 per o don't worry about returning e.g. 3 vs 3.0; when we check equality they are considered equal. morning rush hour but return cheaply during evening rush hour by buying the ticket off-peak). ride (including pet costs), even during rush hour. (fare for return ride may also cost up to S4). fare(38, 3, fare( 1, 20, fare( 5, 2e, fare( 5, 2e, fare( 6, 20, fare( 5,29, fare( 11, 20, fare( 7, 65, fare( 7, 65, fare( 100, 65, fare( 14, 35, fare( 14, 50, False, False, False, False, False, True, True, False, False, True, False, True, False, ) False, 15) False, ) True, ) True, ) False, ) False, 0) False, ) True, ) False, 0) True, 3) False, 100) 16 5 10 11 8 12 3 6 4 # kids ride free # $1 ride plus 15*$1 for pet transport" $16 # same rules as staple-fare #buying return fare, 5+5-$10 # 5.5*2=511; buying a cheap ticket for the ride home! # rush hour pricing # rush hour pricing senior citizen pays half of the usual $6 fare # twice the cost of senior going 7 stops # even during rush hour seniors never pay over $4 23.5 "combination of rules: 8.75+3pets, two trips 112 # combination of rules: rush hour with lots of pets

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!