Question

o o Write a function, computeFare(), that takes as two parameters: the zone and the ticket type, and returns the Long Island

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PYTHON PROGRAM:

def computeFare(zone, ticketType):

fare = 0


if zone == 1 and ticketType == "peak":

fare = 8.75

elif zone == 1 and ticketType == "off-peak":

fare = 6.25   

elif (zone == 2 or zone == 3) and ticketType == "peak":

fare = 10.25

elif (zone == 2 or zone == 3) and ticketType == "off-peak":

fare = 7.50

elif zone == 4 and ticketType == "peak":

fare = 12.00

elif zone == 4 and ticketType == "off-peak":

fare = 8.75

elif (zone == 5 or zone == 6 or zone == 7) and ticketType == "peak":

fare = 13.50

elif (zone == 5 or zone == 6 or zone == 7) and ticketType == "off-peak":

fare = 9.75

else:

fare = -1

return(fare)

def main():

z = int(input("Enter the number of zones: "))

t = input("Enter the ticket type (peak/off-peak): ").lower()

fare = computeFare(z, t)

print('The fare is', fare)

if __name__ == "__main__":

main()

Add a comment
Know the answer?
Add Answer to:
O o Write a function, computeFare(), that takes as two parameters: the zone and the ticket type, ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT