Introduction
Roller coaster is a small programming exercise made with python programming. It is easy to understand and apply the project.
The Roller coaster python exercise implements the control statements and their concepts. It is a python version 3.9 based program. The program uses nested if statements. The program asks the user to enter their height. If the height is above 120cm they can ride the roller coaster.
But they need to buy the ticket first. Also, the program asks you if you want to take photos or not. If yes, you must pay else no pay. The total bill is calculated based on the tickets. It is a console based beginner-level program. See the code below.
print("Welcome to roller coaster!") height = int(input("What is your height in cm? ")) bill = 0 if height > 120: print("You can ride. Bye a ticket.") age = int(input("What is your age? ")) if age < 12: bill = 5 print("Child tickets are $5. ") elif age <= 18: bill = 7 print("Youth tickets are $7.") else: bill = 12 print("Adult tickets are $12. ") wants_photo = input("Do you want a photo taken? Y or N. ") if wants_photo == "Y": bill += 3 print(f"Your final bill is {bill}") else: print("Sorry, You cannot ride")