Assignment: Control Flow in Python
Instructions:
Attempt all questions.
Submit your completed assignment by Monday, June 9, 2025.
After submission, an exam out of 30 marks will be conducted on Wednesday, June 11,
2025 (upon common agreement in place of final exam).
Topics Covered:
for loops
while loops
Objective:
This assignment aims to assess your understanding of control flow in Python, particularly loop
structure (for and while). You will implement various looping techniques to solve problems
efficiently.
Submission Details:
Ensure that your code is well-documented with comments explaining the logic behind your
solutions. Your submission should be in a printed format.
1. Write a program that prints numbers from 1 to 10 using a for loop.
2. Modify the above program to print numbers in reverse order (10 to 1).
3. Print all even numbers from 1 to 20 using a for loop.
4. Write a program that calculates the sum of numbers from 1 to 50 using a for loop.
5. Find the product of all numbers from 1 to 10 using a for loop.
6. Write a Python program that prints the multiplication table of any number provided by
the user.
7. Write a Python program that contains names of students, iterate through a list of names
and print each name.
8. Using a for loop, count the number of vowels in a given string.
9. Write a program that prints all prime numbers between 1 and 100 using for loops.
10. Write a Python program to generate Fibonacci series up to `n` terms using a for loop.
11. Write a Python program to convert a list of numbers into their squares using a loop.
12. Write a Python program that prints numbers from 1 to 10 using a while loop.
13. Write a Python program to print all odd numbers between 1 and 50 using a while loop.
14. Write a Python program to calculate the sum of digits in a number using a while loop.
15. Write a Python program that keep asking the user for input until they enter "exit".
16. Write a Python program to find the factorial of a number using a while loop.
17. Write a Python program that ask the user to input a password, and keep asking until they
enter the correct one.
18. Write a while loop that prints squares of numbers until the squared value exceeds 1000.
19. Implement a basic banking system where the user enters deposits and withdrawals until
they decide to quit.
20. Write a Python program to simulate a simple login system where a user gets three
chances to enter the correct password.
21. Write a program that finds the largest number in a list using a for loop.
22. Write a Python program to print all numbers from 1 to 100 that are divisible by both 3
and 5 using for loop.
23. Write a Python program to finds and prints the greatest common divisor (GCD) of two
numbers.
24. Write a Python program to calculate compound interest using while loop.
25. Write a Python program to simulate a basic traffic light system where the program runs
in a loop until stopped.