CodingNic

Loops and Iteration

Loops Challenges and Projects

Loops and Iteration 30 min read

Loops Challenges and Projects

Loops Challenges and Projects

Great job finishing this module.

You have learned how to use:

  • for loops
  • while loops
  • range()
  • break
  • continue
  • nested loops
  • enumerate()
  • zip()
  • loop patterns

Now it is time to practice everything together.

Quick Challenges

Try to solve these on your own.

Challenge 1: Count to 10

Build a counting program.

Steps:

  • Use a loop
  • Print numbers from 1 to 10

Challenge 2: Even Numbers

Build an even number printer.

Steps:

  • Use a loop
  • Print even numbers from 2 to 20

Challenge 3: Skip Number 5

Build a skip program.

Steps:

  • Use a loop
  • Print numbers from 1 to 10
  • Skip number 5

Challenge 4: Countdown

Build a countdown program.

Steps:

  • Use a loop
  • Print numbers from 5 to 1
  • After the loop, print:
    Go!

Mini Projects

These projects combine many skills.

Project 1: Multiplication Table

Build a multiplication table for one number.

Steps:

  • Ask the user to enter a number
  • Use a loop
  • Print the number multiplied by 1 to 10

Example for 3:

text
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9

Project 2: Password Attempts Checker

Build a password checker with retries.

Steps:

  • Store the correct password as python123
  • Give the user 3 chances to enter the password
  • If the password is correct, print:
    Access granted
  • If all 3 chances are used, print:
    Account locked

Project 3: Numbered Menu

Build a menu using enumerate().

Steps:

  • Create these items:
    Home, Profile, Settings
  • Use enumerate() starting from 1
  • Print each item with its number

Expected output:

text
1 Home
2 Profile
3 Settings

Project 4: Product Price List

Build a price list using zip().

Steps:

  • Create product names:
    Book, Pen, Bag
  • Create prices:
    10, 2, 25
  • Use zip()
  • Print each product with its price

Expected output:

text
Book 10
Pen 2
Bag 25

Final Challenge

Build a mini guessing game.

Steps:

  • Store the secret number as 7
  • Ask the user to guess the number
  • Keep asking until the guess is correct
  • If the guess is correct, print:
    Correct!

Example output:

text
Enter guess: 3
Enter guess: 5
Enter guess: 7
Correct!

Real World Use Case

Loops are used in games, timers, reports, menus, automation tools, and systems that repeat tasks many times.

Quiz

  1. Which loop is best when you know how many times to repeat?
  2. Which loop runs while a condition is true?
  3. What does break do?
  4. What does continue do?

Assignment

Choose one mini project and improve it by adding better messages, more features, or cleaner output.

Summary

You completed the Loops module and practiced real challenges using repetition, counting, patterns, and loop tools in Python.