Question Bank
CS3002 Python Programming
Unit-II: Control Statements
1. What are control statements in Python?
2. Write the syntax of an if – else statement in Python.
3. Which control statement is used to exit from a loop?
4. Which keyword is used in Python for multi-way branching?
5. Write the output of:
6. for i in range(3):
7. print(i, end=" ")
8. Which statement is used to skip the current iteration of a loop?
9. Write syntax of while loop and for loop.
10. What is range() function ?
11. Why indentation required in loops and if statement ?
12. What is the purpose of the else clause in a loop?
13. Explain the difference between if and if-else with examples.
14. What is the use of the elif keyword? Write an example.
15. Write a program to check whether a number is positive, negative, or zero.
16. Explain the difference between for and while loops with examples.
17. Write a Python program to print numbers from 1 to 5 using a while loop.
18. Differentiate between break and continue with suitable examples.
19. Write a Python program to display all even numbers from 1 to 10 using a for loop.
20. Explain nested if statements with a small example.
21. Write a program to calculate the sum of numbers from 1 to 10 using a loop.
22. What is an infinite loop? Give one example in Python.
23. Explain different types of control statements in Python with syntax and examples.
24. Write a program to find the largest among three numbers using if-elif-else.
25. Write a program to calculate the factorial of a number using a while loop.
26. Write a program to check whether a given year is a leap year or not.
27. Explain the role of break, continue, and pass statements with examples.
28. Write a Python program to print the multiplication table of a given number using a loop.
29. Explain else with for loop and while loop using examples.
30. Write a program to print numbers from 1 to 50, but skip multiples of 5.
31. Write a program to find the sum of digits of a number using a loop.
32. Explain how nested loops work with an example of printing a pattern.
33. Write a Python program to print the following pattern using nested loops:
*
**
**
***
34. Write a program to generate the Fibonacci series up to n terms using a loop.
35. Write a program to check whether a given number is prime or not using control
statements.
36. Write a program that asks the user to enter marks and prints grade according to the
following:
90–100 → A
75–89 → B
50–74 → C
Below 50 → Fail
37. Write a program to display the sum of all odd numbers between 1 and 100.