If statements
In this context, the statement represents a timer. I decide to take a nap for 30 minutes. If 30 minutes have passed, then the alarm tells me to wake up
%%python
minutes_passed = 30
def sound_alarm():
print("Wake up!")
if minutes_passed >= 30:
sound_alarm()
Wake up!
If else statements
%%python
# Example
number = 15
if number > 17:
print("Adult")
else:
print("Minor")
Minor
Nested conditionals
This is a nested conditional with booleans
%%python
# Weather conditions
is_raining = False
is_sunny = True
is_cloudy = False
# Determine the weather situation
if is_raining:
print("It's raining.")
elif is_sunny:
print("It's a sunny day!")
elif is_cloudy:
print("It's cloudy but no rain.")
else:
print("The weather is unpredictable today.")
It's a sunny day! Enjoy the sunshine.