← back to unit
Easy
# basics conditionals
Your First if
An if statement runs a block of code only if a condition is True. Notice the colon : and the indented line underneath — that indented part only runs when the condition holds:
age = 20
if age >= 18:
print("You can vote!")
If age were 10 instead, nothing would print at all.
Your turn: read a number age. If age is 18 or more, print You can vote! — otherwise, print nothing.
💡 need a hint?
pyb-cond-if.py🔒 given lines are locked — write your code in between
loading...