Pair Programming Practice (Solutions)

1. The Countdown

Write a loop that counts down from 10 to 1, then prints "Happy New Year!".

for i in range(10, 0, -1): print(i) # Indented: Inside the loop print("Happy New Year!") # Not Indented: After loop
Start
Waiting...

2. Summation (Accumulator)

Calculate the sum of all numbers from 1 to 100 and print the final result.

total = 0 for i in range(1, 101): total = total + i # Indented: Adds every time print(total) # Not Indented: Prints once at end
(Visualizer simplified to range 1-5)
Current i
1
+
total 0
total = 0 + 1