Python uses indentation instead of curly braces. The colon after the condition is required:
score = 85
if score >= 90:
print("A")
elif score >= 70:
print("B")
elif score >= 50:
print("C")
else:
print("F")
Important: indentation must be consistent — always 4 spaces (Python standard).
x == y # equal
x != y # not equal
x > y # greater than
x < y # less than
x >= y # greater than or equal
# Logical operators
x > 0 and x < 10 # both conditions must be true
x < 0 or x > 100 # at least one condition must be true
not True # False
Write a function traffic_light(color):
"red" → "Stop!""yellow" → "Caution!""green" → "Go!""Unknown color"Click "Run" to execute your code.