Lesson 6 of 55
PythonControl Flow – If Statements
20 minutes
Course progress11%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 6 of 55
Python20 minutes
Keep these ideas in mind as you work through the lesson.
Conditional statements let your program choose different paths based on runtime data. Python uses if, elif, and else blocks, each terminated by a colon and an indented body.
temperature = 23
if temperature > 30:
print("It's hot!")
elif temperature > 20:
print("Nice weather")
else:
print("It's cold")
Remember that Python enforces indentation (typically 4 spaces) to define code blocks – no braces needed!