Loops and Repeated Work Python practice problems
for, while, counters, accumulators, ranges, and stopping conditions.
Core concepts
Problem-solving patterns
- for loop · accumulator
- factorial · loop
- range · formatting
- while loop · digits
- while loop · modulo
What this topic builds
Learn the idea once, use it across the exercises, and explain why your approach works.
All 20 problems in this topic
Work from top to bottom to build the concept gradually.
- #041Sum the first n integers: Weekly countersStarterPremium
Add counters numbered 1 through 10 for a simple progress total.
- #042Sum the first n integers: Empty rangeStarterPremium
Confirm that summing through zero leaves the initial total unchanged.
- #043Calculate a factorial: Arrangement countStarterPremium
Find the number of arrangements of six distinct display items.
- #044Calculate a factorial: Zero factorialStarterPremium
Verify the factorial definition for an empty arrangement.
- #045Print a multiplication table: Practice tableBeginnerPremium
Generate the standard ten-line multiplication table for 7.
- #046Print a multiplication table: Negative tableBeginnerPremium
Observe the same loop with a negative base number.
- #047Count digits in an integer: Large invoice numberBeginnerPremium
Count how many digits appear in an invoice identifier.
- #048Count digits in an integer: Signed single digitBeginnerPremium
Ignore the minus sign when counting a negative single-digit value.
- #049Reverse an integer: Reverse an access codeBeginnerPremium
Reverse the digits of a numeric access code.
- #050Reverse an integer: Negative value with zerosBeginnerPremium
Reverse a negative number and naturally discard leading zeros in the result.
- #051Check a numeric palindrome: Symmetric codeBeginnerPremium
Check whether a five-digit gate code reads the same backward.
- #052Check a numeric palindrome: Ordinary numberIntermediatePremium
Reject a number whose reverse is different.
- #053Test primality: Prime identifierIntermediatePremium
Check whether 29 can be used as a prime-sized hash table example.
- #054Test primality: Small edge caseIntermediatePremium
Remember that 1 is neither prime nor composite.
- #055List primes up to n: Small prime catalogIntermediatePremium
List all prime numbers that do not exceed 20.
- #056List primes up to n: Boundary primeIntermediatePremium
Include the upper bound when it is itself prime.
- #057Generate Fibonacci terms: Ten-term sequenceIntermediatePremium
Generate ten Fibonacci terms for a learning dashboard.
- #058Generate Fibonacci terms: Single-term edge caseAdvancedPremium
Return only the starting value when one term is requested.
- #059Find GCD and LCM: Align maintenance cyclesAdvancedPremium
Find when 18-day and 24-day maintenance cycles align, along with their GCD.
- #060Find GCD and LCM: Coprime valuesAdvancedPremium
Calculate GCD and LCM for values that share no factor above 1.