The if-elif-else

The if-elif-else Chain:
Python executes only one block in an if-elif-else chain. It runs each conditional test in order until one passes. When a test passes, the code following that test is executed and Python skips the rest of the tests.

1.To determine the person admission rate?
age=12
if age < 4:
print("Your admission cost is $0.")
elif age < 18:
print("Your admission cost is $5.") 
else:
print("Your admission cost is $10.")

OUTPUT:
Your admission cost is $5.
If-Elif-Else
If-Elif-Else
Translate »