§ 2.5.1section 11 of 18·~4 min
if, elif and else
amount = 750
if amount >= 1000:
tier = "high"
elif amount >= 500:
tier = "medium"
else:
tier = "low"
print(tier)
OUTPUT
mediumPython checks conditions from top to bottom and runs the first one that's True. Combine checks with and, or and not.
city, is_paid = "Pune", True
if city == "Pune" and is_paid:
print("ship from the Pune warehouse")
watch out == compares two values. A single = assigns a value. Mixing them up is one of the most common beginner bugs.