if Statement
noun
say it: “if STAYT-ment” /ɪf ˈsteɪtmənt/
A Python statement that runs a block of code only when a condition is true.
What is an if statement?
An if statement runs a block of code only when a condition is true.
temperature = 95
if temperature > 90:
print("Stay hydrated!")
In a sentence
- “The if statement prints "Stay hydrated!" when it's over 90 degrees.”
- “An if statement checks the coupon code before taking money off.”
Level: Novice · More Python terms at this level
Updated