Question: 43. Due Date: 13 November Reading: Think CS: Chapter 6 Write a function, computeFare), that takes as two parameters: the zone and the ticket type,


43. Due Date: 13 November Reading: Think CS: Chapter 6 Write a function, computeFare), that takes as two parameters: the zone and the ticket type, and returns the MetroNorth Railroad fare. If the zone is 1 and the ticket type is "peak", the fare is 6.75. If the zone is 1 and the ticket type is "off-peak", the fare is 5.00 o If the zone is 1 and the ticket type is "senior", the fare is 3.25. If the zone is 2 and the ticket type is "peak", the fare is 7.50. o If the zone is 2 and the ticket type is "off-peak", the fare is 5.75 o If the zone is 2 and the ticket type is "senior", the fare is 3.75 If the zone is 3 and the ticket type is "peak", the fare is 9.25 o If the zone is 3 and the ticket type is "off-peak", the fare is 7.00 o If the zone is 3 and the ticket type is "senior", the fare is 4.50 o If the zone is greater than 3, return a negative number (since your calculator does not handle inputs that high) A template program, MNRtransit.py, is available on the CSci 127 repo on github. The grading script does not run the whole program, but instead tests your function separately (unit tests') to determine correctness. As such, the name of the function must match exactly (else, the scripts cannot find) A sample run: Enter the number of zones: 2 Enter the ticket type (peak/off-peak): off-peak The fare is 5.75 And another: Enter the number of zones: 6 Enter the ticket type (peak/off-peak): peak The fare is -1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
