Today we teach Python what to do when a condition is False.
if condition:
print("YES")
else:
print("NO")
age = int(input("Enter age: "))
if age >= 18:
print("Eligible")
else:
print("Not eligible")
"Even", else print
"Odd".
Only one path is taken. The other is ignored.
if–else, today is
complete.
Preview of tomorrow: multiple conditions using elif.
if marks >= 90:
print("A")
elif marks >= 60:
print("B")
else:
print("Fail")
Output will appear here…