RisingCoder Full course โ†’
Day 1Day 2Day 3Day 4
๐ŸŒ€
STUDENT NOTES ยท DAY 6 OF 24

Loop Tricks & Patterns ๐ŸŒ€

Loops inside loops, skipping the boring bits, and collecting totals โ€” the tricks that turn loops into superpowers.

1A loop inside a loop

๐Ÿ
Py: Think of a school timetable: for every DAY, go through every PERIOD. That's a loop inside a loop!
๐Ÿฆ‰
Professor Hoot: The outer loop moves once; the inner loop runs ALL its rounds each time. 2 outer ร— 3 inner = 6 lines.

2continue โ€” skip this one, keep going

๐Ÿค–
Bittu: continue = skip the rest of THIS round and move to the next. break = leave the loop completely. Different exits!

3The collector pattern

Start with an empty total, add to it every round โ€” how programs sum anything:

4Star patterns! โญ

Pyramid builder โ€” slide the height!

height = 4
โ˜…
โ˜…โ˜…
โ˜…โ˜…โ˜…
โ˜…โ˜…โ˜…โ˜…

5Quick quiz! ๐Ÿง 

How many lines print?
for i in range(3):
  for j in range(2): print(i, j)
๐Ÿ’ก Outer runs 3 times, inner runs 2 per outer round: 3 ร— 2 = 6 lines.
Inside a loop, continue does what?
๐Ÿ’ก It abandons the current round and jumps straight to the next one.

6Your mission ๐Ÿš€

Mission 1: Print numbers 1โ€“20, but SKIP all numbers divisible by 3 (hint: % and continue).
Mission 2: Add up all numbers from 1 to 100 with the collector pattern. (Check: it's 5050!)
Mission 3: Build an UPSIDE-DOWN star pyramid. ๐Ÿ™ƒ

Day 6 done โ€” pattern master! ๐ŸŒ€

Next: lists โ€” one variable that holds a whole class of students.

Go to Day 7: Lists โ†’

๐ŸŽฎ Or test yourself in the Python Arcade โ†’