0% found this document useful (0 votes)
3 views

Python Loop Questions

The document contains a series of Python loop practice questions categorized into basic and intermediate levels. Basic questions include tasks like printing numbers, calculating sums, and manipulating strings using loops. Intermediate questions involve more complex tasks such as finding prime numbers, calculating GCD, and generating Fibonacci sequences.

Uploaded by

kotasriharshit
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python Loop Questions

The document contains a series of Python loop practice questions categorized into basic and intermediate levels. Basic questions include tasks like printing numbers, calculating sums, and manipulating strings using loops. Intermediate questions involve more complex tasks such as finding prime numbers, calculating GCD, and generating Fibonacci sequences.

Uploaded by

kotasriharshit
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Python Loop Practice Questions

Basic and Intermediate Levels


Basic Questions
1. Write a program to print numbers from 1 to 20 using a for loop.
2. Print the square of numbers from 1 to 10 using a for loop.
3. Write a program to print 'Hello, World!' 5 times using a while loop.
4. Print all the elements of a list: fruits = ['apple', 'banana', 'cherry'] using a for loop.
5. Write a program to print numbers from 10 to 1 in reverse using a while loop.
6. Write a program to print all the even numbers between 1 and 50 using a for loop.
7. Print the first 10 multiples of 5 using a for loop.
Basic Questions (Continued)
8. Write a program to calculate the sum of digits of a given number using a while loop.
9. Print each character of the string 'Python' using a for loop.
10. Write a program to continuously ask the user for input until they type 'exit'.
11. Use a loop to calculate the factorial of a given number.
12. Write a program to find the length of a list without using the len() function.
13. Print numbers from 1 to 10, but skip 5 using continue.
Intermediate Questions
1. Write a program to calculate the sum of all odd numbers between 1 and 50 using a loop.
2. Find the product of all numbers in this list: [1, 2, 3, 4, 5] using a loop.
3. Write a program to count the number of vowels in a user-provided string using a loop.
4. Print the multiplication table of a user-provided number using a for loop.
5. Reverse a given string using a loop (without slicing).
6. Write a program to find the maximum number in a list using a loop.
7. Count the occurrences of each element in a list using a loop.
8. Write a program to print this pattern using nested loops:
*
**
***
****
*****
9. Write a program to check whether a number is a palindrome using a loop.
10. Print this pattern using nested loops:
*****
****
***
**
*
Intermediate Questions
(Continued)
nd the second largest number in a list using a loop.
Write a program to print all prime numbers between 1 and 100 using a loop.
ount the number of words in a sentence using a loop.
Write a program to calculate the sum of all numbers in a list without using built-in functions.
reate a program to generate a Fibonacci sequence up to n terms using a loop.
rint this pattern using nested loops:

**
***
*****
Write a program to flatten a nested list using loops only.
nd the greatest common divisor (GCD) of two numbers using a loop.
Write a program to print elements of two lists alternatively using a single loop.
Write a program to create a list of cumulative sums from another list, e.g., [1, 2, 3, 4] becomes [1, 3, 6

You might also like