1.
Simple Range
Write a for loop to print all numbers from 1 to 20.
2. Sum of Odd Numbers
Use a for loop to calculate the sum of all odd numbers from 1 to 50.
3. Iterating Over Strings
Write a for loop to print each character in the string "Python is fun!".
4. Factorial Calculation
Write a for loop to calculate the factorial of a number n. For example, if n = 5,
the result should be 5 * 4 * 3 * 2 * 1 = 120.
5. List Squaring
Given the list numbers = [2, 4, 6, 8, 10], write a for loop to print the square of
each number.
6. Counting Vowels
Write a for loop to count the number of vowels in the string "Hello, World!".
7. Reversing a String
Use a for loop to reverse the string "Python" and print the result.
8. Cumulative Sum
Write a for loop to calculate the cumulative sum of numbers in the list nums = [10,
20, 30, 40].
9. Finding Maximum
Use a for loop to find the maximum value in the list nums = [5, 12, 7, 22, 15].
10. Iterating Over Nested Lists
Given the nested list matrix = [[1, 2], [3, 4], [5, 6]], write a for loop to print
each element.
11. Counting Words
Write a for loop to count how many words are in the sentence "I love programming
with Python.".
12. Fibonacci Sequence
Write a for loop to generate the first 10 numbers in the Fibonacci sequence.