Beginner Exercises for "for Loop" Statements in Python

Arzath AreeffArzath Areeff
1 min read

1. Print 1 to 10

Use a for loop to print numbers 1 to 10.

2. Sum of 1 to 100

Use a for loop to calculate the sum of numbers from 1 to 100.

3. Print Multiples of 3 (1–30)

Print all multiples of 3 between 1 and 30.

4. Print Each Character

Ask the user to enter a word. Print each letter using a loop.

5. Factorial Calculator

Ask the user for a number n. Calculate the factorial of n using a loop.


ANSWERS

1. Print 1 to 10

for i in range(1, 11):
    print(i)

2. Sum of 1 to 100

total = 0
for i in range(1, 101):
    total += i
print("Sum is", total)

3. Multiples of 3 (1–30)

for i in range(1, 31):
    if i % 3 == 0:
        print(i)

4. Print Each Character

word = input("Enter a word: ")
for letter in word:
    print(letter)

5. Factorial Calculator

num = int(input("Enter a number: "))
fact = 1
for i in range(1, num + 1):
    fact *= i
print("Factorial is", fact)
0
Subscribe to my newsletter

Read articles from Arzath Areeff directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Arzath Areeff
Arzath Areeff

I co-founded digizen.lk to promote online safety and critical thinking. Currently, I’m developing an AI app to fight misinformation. As Founder and CEO of ideaGeek.net, I help turn startup dreams into reality, and I share tech insights and travel stories on my YouTube channels, TechNomad and Rz Omar.