Loading…
An if statement runs code only when a condition is true.
age = 18
if age >= 18:
print("You are an adult")
Important: Code inside if must be indented (4 spaces).
| Operator | Meaning |
|---|---|
| == | Equal to |
| != | Not equal |
| > | Greater than |
| < | Less than |
| >= | Greater or equal |
| <= | Less or equal |
Create a variable score = 85. If it's greater than or equal to 70, print "Pass".
Downloading Python… (one-time, ~10 MB)
This runs entirely in your browser and is cached for next time.