Roller coaster eligibility

EasyIf-Else Programs · 48 of 64

Write a Python program to check whether a person can ride a roller coaster: eligible when age is greater than 12.

Advertisement
Input
15, 12
Output
15 -> You are eligible
12 -> You are not eligible

Approach

  1. Compare the age with 12 using >.

Solution

Python
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.

Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More if-else programs

← All 64 If-Else Programs