ProgramsPython

Loop Programs

for and while. Digits, patterns, Fibonacci. You will get tired of range() and that is the point.

25 programs · open one, then the next

The matching chapter is Day 9: Loops and Iteration in the Python course. For a short check, try the Python quiz (300 questions). Every topic is listed on Python exercises.

Start with Print Numbers 1–100
  1. 01Print Numbers 1–100BeginnerUse a loop to print numbers from 1 to 100.Open example →
  2. 02Print Even Numbers in RangeBeginnerPrint all even numbers between 1 and a given upper limit.Open example →
  3. 03Print Odd Numbers in RangeBeginnerPrint all odd numbers between 1 and a given upper limit.Open example →
  4. 04Sum of DigitsBeginnerCompute the sum of digits of an integer using a loop.Open example →
  5. 05Reverse Digits of a NumberBeginnerReverse the digits of an integer using a loop.Open example →
  6. 06Calculate Factorial (Loop)BeginnerCalculate the factorial of a non-negative integer using a loop.Open example →
  7. 07Fibonacci SeriesBeginnerPrint the first N terms of the Fibonacci sequence using a loop.Open example →
  8. 08Palindrome Number CheckBeginnerCheck whether an integer is a palindrome using digit reversal.Open example →
  9. 09Count Digits in a NumberBeginnerCount how many digits an integer has using a loop.Open example →
  10. 10GCD of Two Numbers (Loop)BeginnerCompute the greatest common divisor (GCD) of two integers using the Euclidean algorithm.Open example →
  11. 11LCM of Two Numbers (Loop)BeginnerCompute the least common multiple (LCM) of two integers using GCD.Open example →
  12. 12Print Prime Numbers in RangeBeginnerPrint all prime numbers in a given inclusive range.Open example →
  13. 13Count Prime Numbers in RangeBeginnerCount how many prime numbers appear in a given inclusive range.Open example →
  14. 14Check Composite NumberBeginnerCheck whether a number is composite (non-prime, greater than 1).Open example →
  15. 15Power of 2 CheckerBeginnerCheck whether a positive integer is a power of 2 using a loop.Open example →
  16. 16Print Number PatternBeginnerPrint a basic right-angled triangle number pattern using nested loops.Open example →
  17. 17Print Star PatternBeginnerPrint a right-angled triangle star pattern using nested loops.Open example →
  18. 18Armstrong Numbers in RangeBeginnerPrint all Armstrong numbers in a given range using loops.Open example →
  19. 19Strong Numbers in RangeBeginnerPrint all strong numbers in a given range.Open example →
  20. 20Sum of Series 1/1 + 1/2 + … + 1/NBeginnerCompute the sum of the harmonic series up to N terms.Open example →
  21. 21Print Multiplication SeriesBeginnerPrint a multiplication series for a number in a compact single-line format.Open example →
  22. 22Print Pyramid PatternBeginnerPrint a centered pyramid of stars using nested loops.Open example →
  23. 23Print Inverted Pyramid PatternBeginnerPrint an inverted centered pyramid of stars.Open example →
  24. 24Print Floyd's TriangleBeginnerPrint Floyd's triangle (consecutive numbers in a right-angled triangle).Open example →
  25. 25Print Pascal's TriangleIntermediatePrint Pascal's triangle up to N rows using a loop and binomial coefficients.Open example →