Control Flow: Interactive Python Lessons
Master if/else conditionals, for and while loops, and boolean logic through hands-on Python control flow practice problems — the building blocks of every real program.
58 lessons in this topic. Every lesson runs real Python in your browser with instant feedback.
If Statements
Make decisions in your code
Loops - For
Repeat code multiple times
If-Else Statement
Handle both true and false cases
Elif Statement
Check multiple conditions
While Loop
Repeat code while condition is true
For Loop with Range
Loop through a range of numbers
Using 'break' in Loops
Learn how to use the 'break' statement to exit loops prematurely.
Continue Statement
Skip to next loop iteration
FizzBuzz to 15
For 1..15: print Fizz (÷3), Buzz (÷5), FizzBuzz (both), else the number.
Letter grade for 85
A score of 85: print 'A' (>=90), 'B' (>=80), 'C' (>=70), else 'F'.
Is 2024 a leap year?
Print True if 2024 is a leap year (divisible by 4 and not by 100, or by 400).
Sign of 7
Print 'positive', 'negative' or 'zero' for 7.
Larger of 9 and 4 without max()
Without using max(), print the larger of 9 and 4 using an if.
Age group of 16
For age 16 print 'child' (<13), 'teen' (13-19) or 'adult' (>=20).
FizzBuzz to 20
For 1..20: print Fizz (÷3), Buzz (÷5), FizzBuzz (both), else the number.
Letter grade for 72
A score of 72: print 'A' (>=90), 'B' (>=80), 'C' (>=70), else 'F'.
Is 1900 a leap year?
Print True if 1900 is a leap year (divisible by 4 and not by 100, or by 400).
Sign of -3
Print 'positive', 'negative' or 'zero' for -3.
Larger of 12 and 5 without max()
Without using max(), print the larger of 12 and 5 using an if.
Age group of 11
For age 11 print 'child' (<13), 'teen' (13-19) or 'adult' (>=20).
FizzBuzz to 30
For 1..30: print Fizz (÷3), Buzz (÷5), FizzBuzz (both), else the number.
Letter grade for 68
A score of 68: print 'A' (>=90), 'B' (>=80), 'C' (>=70), else 'F'.
Is 2000 a leap year?
Print True if 2000 is a leap year (divisible by 4 and not by 100, or by 400).
Sign of 0
Print 'positive', 'negative' or 'zero' for 0.
Larger of 3 and 8 without max()
Without using max(), print the larger of 3 and 8 using an if.
Age group of 25
For age 25 print 'child' (<13), 'teen' (13-19) or 'adult' (>=20).
FizzBuzz to 12
For 1..12: print Fizz (÷3), Buzz (÷5), FizzBuzz (both), else the number.
Letter grade for 91
A score of 91: print 'A' (>=90), 'B' (>=80), 'C' (>=70), else 'F'.
Is 2023 a leap year?
Print True if 2023 is a leap year (divisible by 4 and not by 100, or by 400).
Sign of -10
Print 'positive', 'negative' or 'zero' for -10.
Larger of 20 and 20 without max()
Without using max(), print the larger of 20 and 20 using an if.
Age group of 19
For age 19 print 'child' (<13), 'teen' (13-19) or 'adult' (>=20).
FizzBuzz to 18
For 1..18: print Fizz (÷3), Buzz (÷5), FizzBuzz (both), else the number.
Letter grade for 59
A score of 59: print 'A' (>=90), 'B' (>=80), 'C' (>=70), else 'F'.
Is 2100 a leap year?
Print True if 2100 is a leap year (divisible by 4 and not by 100, or by 400).
Sign of 5
Print 'positive', 'negative' or 'zero' for 5.
Larger of 1 and 2 without max()
Without using max(), print the larger of 1 and 2 using an if.
Age group of 13
For age 13 print 'child' (<13), 'teen' (13-19) or 'adult' (>=20).
FizzBuzz to 25
For 1..25: print Fizz (÷3), Buzz (÷5), FizzBuzz (both), else the number.
Letter grade for 77
A score of 77: print 'A' (>=90), 'B' (>=80), 'C' (>=70), else 'F'.
Is 1996 a leap year?
Print True if 1996 is a leap year (divisible by 4 and not by 100, or by 400).
Sign of -1
Print 'positive', 'negative' or 'zero' for -1.
Larger of 15 and 30 without max()
Without using max(), print the larger of 15 and 30 using an if.
Age group of 7
For age 7 print 'child' (<13), 'teen' (13-19) or 'adult' (>=20).
FizzBuzz to 10
For 1..10: print Fizz (÷3), Buzz (÷5), FizzBuzz (both), else the number.
Letter grade for 100
A score of 100: print 'A' (>=90), 'B' (>=80), 'C' (>=70), else 'F'.
Is 2400 a leap year?
Print True if 2400 is a leap year (divisible by 4 and not by 100, or by 400).
Sign of 42
Print 'positive', 'negative' or 'zero' for 42.
Larger of 8 and 8 without max()
Without using max(), print the larger of 8 and 8 using an if.
Age group of 45
For age 45 print 'child' (<13), 'teen' (13-19) or 'adult' (>=20).
FizzBuzz to 50
For 1..50: print Fizz (÷3), Buzz (÷5), FizzBuzz (both), else the number.
Letter grade for 64
A score of 64: print 'A' (>=90), 'B' (>=80), 'C' (>=70), else 'F'.
Is 1999 a leap year?
Print True if 1999 is a leap year (divisible by 4 and not by 100, or by 400).
Sign of -7
Print 'positive', 'negative' or 'zero' for -7.
Larger of 6 and 11 without max()
Without using max(), print the larger of 6 and 11 using an if.
Age group of 20
For age 20 print 'child' (<13), 'teen' (13-19) or 'adult' (>=20).
FizzBuzz to 22
For 1..22: print Fizz (÷3), Buzz (÷5), FizzBuzz (both), else the number.
Letter grade for 92
A score of 92: print 'A' (>=90), 'B' (>=80), 'C' (>=70), else 'F'.