Code·basic
Conditional
Code that runs only when a condition is true — the `if` statement.
A conditional lets your code make decisions.
age = 17
if age >= 18:
print("Adult")
elif age >= 13:
print("Teenager")
else:
print("Kid")
Python checks each condition in order and runs the first block whose condition is true. If nothing matches, else runs.
Conditionals are how programs respond differently to different inputs. Every game, app, and website is ultimately stacks of conditionals deciding what to do next.