Course offer · HLD · LLD · System Design at ₹799 until 30 Nov (not interview packs)

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–100BeginnerCount from 1 through 100 with a Python for loop. A first range exercise explains the excluded stop, required indentation, and the sample’s abbreviated output.Open example →
  2. 02Print Even Numbers in RangeBeginnerGenerate positive even integers directly instead of filtering every number. A beginner Python range exercise explains a step of two and an inclusive input limit.Open example →
  3. 03Print Odd Numbers in RangeBeginnerStart at one and move by two to print odd Python integers. New programmers can predict the final row for even or odd limits and spot an empty forward range.Open example →
  4. 04Sum of DigitsBeginnerPeel digits off 1234 and add them with a Python while loop. Beginner steps connect % 10, // 10, abs, and an accumulator while preserving the original number.Open example →
  5. 05Reverse Digits of a NumberBeginnerRebuild 1234 as 4321 with Python arithmetic rather than string slicing. First-year traces cover place shifting, negative signs, and disappearing leading zeroes.Open example →
  6. 06Calculate Factorial (Loop)BeginnerMultiply 1 through N to calculate a Python factorial. A beginner loop lesson explains the starting value one, 0!, negative-input checks, and growing integers.Open example →
  7. 07Fibonacci SeriesBeginnerKeep just two values to print N Fibonacci terms in Python. Beginners trace tuple unpacking and learn why a term count is different from a numeric upper limit.Open example →
  8. 08Palindrome Number CheckBeginnerReverse a Python integer and compare it with the original to test a palindrome. A first while-loop application includes zero and an explicit negative-sign rule.Open example →
  9. 09Count Digits in a NumberBeginnerCount decimal digits by shrinking a Python integer with // 10. This beginner while-loop exercise ignores the sign and gives zero its proper one-digit count.Open example →
  10. 10GCD of Two Numbers (Loop)BeginnerReduce 54 and 24 to their GCD with Python’s Euclidean loop. A beginner pair-by-pair trace explains remainder updates, tuple unpacking, zero inputs, and signs.Open example →
  11. 11LCM of Two Numbers (Loop)BeginnerUse a Euclidean GCD to calculate a Python least common multiple. Beginners preserve original inputs, apply the product identity, and guard the both-zero case.Open example →
  12. 12Print Prime Numbers in RangeBeginnerSearch a Python interval for primes using a fresh divisor test per candidate. First-year loops practice covers square-root bounds, flags, continue, and break.Open example →
  13. 13Count Prime Numbers in RangeBeginnerCount primes without building a result list in Python. Beginners separate the total from each candidate’s flag and trace inclusive endpoints and empty intervals.Open example →
  14. 14Check Composite NumberBeginnerOne proper factor proves a Python integer composite. A beginner search explains the square-root boundary, early stopping, and why one is not a prime fallback.Open example →
  15. 15Power of 2 CheckerBeginnerKeep dividing a Python integer by two until it is odd. New programmers test the remaining value, include 2⁰, and see why zero needs a guard before the loop.Open example →
  16. 16Print Number PatternBeginnerPrint rows 1, then 1 2, then 1 2 3 with Python nested loops. Beginner steps separate row and column work and show exactly where the newline belongs.Open example →
  17. 17Print Star PatternBeginnerDraw a growing Python star triangle without an inner loop. A first pattern exercise uses string repetition and connects each row index with its visible width.Open example →
  18. 18Armstrong Numbers in RangeBeginnerSearch a Python interval for powered-digit matches, including every single digit. Beginners reset the sum and digit count for each Armstrong-number candidate.Open example →
  19. 19Strong Numbers in RangeBeginnerFind 1, 2, and 145 in a Python factorial-digit search. First-year nested-loop practice resets each candidate and avoids falsely including zero in the results.Open example →
  20. 20Sum of Series 1/1 + 1/2 + … + 1/NBeginnerAdd 1/1 through 1/N with Python true division and a running float total. Beginners trace reciprocal terms and see why floor division would destroy the series.Open example →
  21. 21Print Multiplication SeriesBeginnerCollect Python multiplication terms and print them on one line. A beginner list-and-join exercise keeps separators between terms instead of after the last one.Open example →
  22. 22Print Pyramid PatternBeginnerCenter Python star rows by shrinking spaces and growing odd widths. A beginner pattern walkthrough derives both formulas and checks the three-row output.Open example →
  23. 23Print Inverted Pyramid PatternBeginnerTurn a Python star pyramid upside down by reversing row traversal. Beginners follow a negative range step while keeping the same padding and width formulas.Open example →
  24. 24Print Floyd's TriangleBeginnerKeep a Python counter running across triangle rows instead of restarting at one. A beginner nested-loop trace explains row lengths and newline placement.Open example →
  25. 25Print Pascal's TriangleIntermediateProduce Pascal coefficients with exact Python integer updates. First-year nested-loop practice resets each row to one and traces the next-value recurrence.Open example →