Created
December 30, 2017 09:51
-
-
Save morisasy/180721da6d06d3567fa8ab0ce22a412a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
def bus_fares(age): | |
""" | |
The bus fares program will print appropriate price for a particular age group. | |
User should enter a age and the program will suggest the price. | |
Parameters: | |
age: enter age as number: | |
""" | |
#change the age to experiment with the pricing | |
##age = 35 | |
#set the age limits for bus fares | |
free_up_to_age = 4 | |
child_up_to_age = 18 | |
senior_from_age = 65 | |
#set bus fares | |
concession_ticket = 1.25 | |
adult_ticket = 2.50 | |
#ticket price logic | |
if age <= free_up_to_age: | |
ticket_price = 0 | |
elif age <= child_up_to_age: | |
ticket_price = concession_ticket | |
elif age >= senior_from_age: | |
ticket_price = concession_ticket | |
else: | |
ticket_price = adult_ticket | |
message = "Somebody who is {} years old will pay ${} to ride the bus.".format(age,ticket_price) | |
return(message) | |
print(bus_fares(13)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment