Question: Write a function ticket price(), which takes three arguments, in the following order: base price: an integer that gives the base (regular) price of a

Write a function ticket price(), which takes three arguments, in the following order:

base price: an integer that gives the base (regular) price of a train ticket

membership: a string that indicates the travel membership class of a train passenger: platinum, gold, silver or bronze

age: an integer that indicates a train passengers age

The function uses these three values to compute and return the final ticket price that a particular train passenger must pay, based on his/her membership class and age. Unfortunately, we dont have a nice, neat explanation of how to use these three values. All we have to go by is the following hastily written email from the train companys marketing department:

Sorry for the rush on this, but we need this program working ASAP. Right, so, platinum members and younger passengers (less than 65 years old) have to pay a $6 premium on the regular ticket price. Yeah, doesnt seem fair, but thats what management wants. No, it doesnt matter what membership the younger passengers are in just slap on the $6 charge. Gold and silver members always pay a $4 premium. Now, I know what youre thinking but what about the less than 65 years old rule? First check if the traveler is less than 65 and if so, hit them with that $6 charge. Only if the passenger is 65 or older AND a gold or silver member should you assess the $4 charge. Sorry if this is confusing. Now, older bronze members (older means 65 or older) pay a $2 premium; younger bronze members will have to pay that $6 premium I told you about earlier because theyre younger members (so the bronze status is actually irrelevant here). Hope this makes sense talk to your supervisor if you have questions.Write a function ticket price(), which takes three arguments, in the following

Examples: Return Value Function Arguments 100, 'platinum', 77 106 100, 'platinum, 21106 100, gold, 25 50, 'gold', 71 60,'silver', 67 90, 'bronze', 67 60, bronze, 45 106 54 64 92

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!