Conditions
Prerequisites: Operators
A condition lets a program make a decision — run one block of code if something is true, and a different block if it's not.
Real-world analogy: "if it's raining, take an umbrella; otherwise, leave it at home." The program checks a condition and picks a path.
if age >= 18:
print("Adult")
else:
print("Minor")
Practice
Describe, in plain steps, how a program would decide whether a number is positive, negative, or zero.
Show solution
if number > 0: it's positive
else if number < 0: it's negative
else: it's zero