Skip to content

Ticket price

Ticket price

Read age with int(input()), then read yes or no for membership: member = input() == "yes" stores True or False. Members pay 5. Everyone else pays 12, or 8 if they are under 18. Print the price.

Order matters: test member first, so a 12-year-old member still pays 5. An 18-year-old is not under 18.

A True/False variable needs no comparison: if member: already asks the question. Writing if member == True: works too, but the short form is what you will see in real code.

Log in or create account

IGCSE, A-Level & AP