30 Python Programming Questions on for loop
Q 1. Write a Program to print numbers from 1 to 5.
Expected Output
1
2
3
4
5
Q 2. Calculate the sum of numbers from 1 to 10.
Expected Output:
55
Q 3. Write a Program to Print all even numbers from 1 to 20.
Expected Output:
2
4
6
8
10
12
14
16
18
20
Q 4. Write a Program to Print the multiplication table of 5.
Expected Output:
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
Q 5. Write a Program to Print numbers from 10 to 1 in descending order.
Expected Output:
10
9
8
7
6
5
4
3
2
1
Q 6. Write a Program to Print the first 5 natural numbers.
Expected Output:
1
2
3
4
5
Q 7. Find the factorial of a number
Input num = 4
Expected Output:
24
Q 8. Print the squares of numbers from 1 to 5.
Expected Output:
1
4
9
16
25
Q 9. Print the sum of the first 5 positive integers.
Expected Output:
15
Q 10. Write a Program to Check if a number is prime.
Input = 7
Expected Output:
Prime
Q 11. Print the Fibonacci sequence up to 10 numbers.
Expected Output:
0
1
1
2
3
5
8
13
21
34
Q 12. Count the number of digits in a number.
Input num = 12345
Expected Output:
5
Q 13. Print a string multiple times (e.g., "Technovlogs" 5 times).
Expected Output:
Technovlogs
Technovlogs
Technovlogs
Technovlogs
Technovlogs
Q 14. Find the sum of even numbers from 1 to 10.
Expected Output:
30
Q 15. Print a triangle pattern of stars.
Q 16. Print the first 5 numbers of the series 2, 4, 6, 8, 10.
Q 17. Print the sum of the squares of numbers from 1 to 5.
Expected Output
55
Q 18. Print numbers from 1 to 10 with a message for multiples of 3.
Expected Output:
1
2
3 is a multiple of 3
4
5
6 is a multiple of 3
7
8
9 is a multiple of 3
10
Q 19. Print the sum of odd numbers from 1 to 10.
Expected Output:
25
Q 20. Print the factorial of numbers from 1 to 5.
Expected Output:
Factorial of 1 is 1
Factorial of 2 is 2
Factorial of 3 is 6
Factorial of 4 is 24
Factorial of 5 is 120
Q 21. Count the number of vowels in a string.
string = "hello world"
Expected Output:
3
Q 22. Write a Program to Print all digits in a string.
string = "abc123def456"
Expected Output:
1
2
3
4
5
6
Q 23. Generate the first 10 squares of numbers.
Expected Output:
1
4
9
16
25
36
49
64
81
100
Q 24. Print the sum of the first 10 positive integers.
Expected Output:
55
Q 25. Print numbers from 1 to 20, but skip multiples of 4.
Expected Output:
1
2
3
5
6
7
9
10
11
13
14
15
17
18
19
Q 26. Print the cube of numbers from 1 to 5.
Expected Output:
1
8
27
64
125
Q 27. Print the reverse of a given string.
string = "python"
Expected Output:
nohtyp
Q 28. Print the first 10 numbers of the Fibonacci sequence.
Expected Output:
0
1
1
2
3
5
8
13
21
34
Q 29. Print numbers from 1 to 20, replacing multiples of 3 with "Fizz" and multiples of 5 with "Buzz".
Expected Output:
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Q 30. Print the sum of the first 10 positive integers squared.
Expected Output:
385
Bikki Singh
Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!