Python Practice › If-Else Programs › Program 48
Roller coaster eligibility
Write a Python program to check whether a person can ride a roller coaster: eligible when age is greater than 12.
Input
15, 12
Output
15 -> You are eligible 12 -> You are not eligible
Approach
- Compare the age with 12 using
>.
Solution
for age in [15, 12]: if age > 12: print(age, "-> You are eligible") else: print(age, "-> You are not eligible")Output
15 -> You are eligible 12 -> You are not eligible
Line by line
Line 2
“Greater than 12” excludes exactly 12.
Learn the concept
New to this topic? Read the lesson, then come back.