Python Practice Set-1: 10 Exercises (For Python Loops)

Karan Ahirwar
2 min readMar 1, 2023

--

10 Exercises For Python Loops practice

  1. Using a while loop, write a program that repeatedly asks the user for their name and only exits the loop when the user enters “done”.
  2. Using a for loop, write a program that prints out the first 20 numbers of the Fibonacci sequence.
  3. Using a while loop, write a program that repeatedly asks the user for a number and only exits the loop when the user enters a number greater than 100.
  4. Using a while loop, write a program that repeatedly asks the user for their favorite color and only exits the loop when the user enters “green”.
  5. Using a for loop, write a program that calculates the factorial of a number given by the user.
  6. Using a for loop, write a program that prints out all the prime numbers between 1 and 100.
  7. Using a for loop, write a program that iterates through a list of words and prints out the length of each word.
  8. Using a for loop, write a program that calculates the average of a list of numbers.
  9. Using a for loop, write a program that sums up all the integers from 1 to 100.
  10. Using a for loop, write a program that prints out the elements of a list in reverse order.

Solution :- https://tiny-isthmus-d13.notion.site/Loop-Practice-15fb0ecf1a704ff0bb032f59c1b91aa0

--

--