← Back to Python Course Foundations
Conditional and Iterative Statements¶
Learning Objectives¶
- Implement decision logic with conditional statements.
- Use while/for loops effectively.
- Control loops with break/continue/pass and loop else.
Example¶
n = 7
if n % 2 == 0:
print("Even")
else:
print("Odd")
for i in range(1, 6):
if i == 3:
continue
print(i)
else:
print("Loop completed")
Dry Run¶
- Prints
Odd - Loop prints
1 2 4 5 - Executes loop
elseblock.
Common Mistakes¶
- Infinite loops in
while. - Wrong indentation causing logic shift.
Practice¶
- Print multiplication table using loop.
- Break loop when user enters 0.