Python for Loop


1) Print Numbers 1–10

Use a for loop to print numbers from 1 to 10.


2) Print Even Numbers 2–20

Use a for loop and range() to print even numbers from 2 to 20.


3) Print Odd Numbers 1–19

Use a for loop and range() to print odd numbers from 1 to 19.


4) Sum of First N Numbers

Ask the user for a number n. Use a loop to compute and print the sum from 1 to n.


5) Print Each Character

Ask user for a word and use a for loop to print each character on a new line.


6) List of Squares

Use a loop to print square of numbers from 1 to 10.


7) Multiply Table

Ask the user for a number and print its multiplication table up to 10.

Example (for 3):


8) Print List Items

Given a list like [5, 10, 15, 20], use a loop to print each item.


9) Count Characters

Ask user for a string. Use a loop to count its characters (don’t use len()).


10) Sum List Elements

Given a list of numbers, use a loop to compute and print their sum.

Example list: [2, 4, 6, 8]


11) Print a Pattern

Use nested loops to print:


12) Loop with Step

Print numbers from 10 down to 1 using range() with a step.


13) Print Alphabet

Use a loop to print letters from 'a' to 'z'.

(Hint: use string.ascii_lowercase or a list of chars.)


14) Count Even Numbers

Ask user for 5 numbers and count how many are even.


15) List of Cubes

Use a loop to create and print a list of cubes from 1 to 10.

Expected:


16) Print Lengths

Ask user to enter 3 words. Use a loop to print each word’s length.


17) Print Index and Value

Given a list, use a loop to print both index and value for each item.

Example:


18) Display Only Positive

Given a list [-2, 3, -1, 5], use a loop to print only positive numbers.


19) Count Vowels

Ask user for a string. Use a loop to count vowels (a, e, i, o, u).


20) Reverse Print

Ask user for a word and use a loop to print it in reverse.


📝 Example Problem Template

Print Even Numbers 2–20:


canvil: 333f6c7d-6876-4f7e-b6ad-1bdb2233f5c1

Last updated