Loops Questions and Answers
Python Programming - Loops Questions with Answers explain repetitive task execution efficiently. These Python Loops Questions are common in Infosys, TCS, and SSC exams testing logical flow control and iteration
Loops
Showing 10 of
25 questions
1. Which loop in Python is used to iterate over a sequence of elements?
- while loop
- for loop
- do-while loop
- repeat loop
3. Which keyword is used to exit a loop prematurely in Python?
- exit
- stop
- break
- return
4. What does the continue statement do in a Python loop?
- Exits the entire loop
- Skips current iteration
- Restarts the loop
- Pauses the loop
5. How many times will this loop execute: while False: print("Hello")
- 0 times
- 1 time
- Infinite times
- 2 times
6. What is the output of: for i in range(1, 5, 2): print(i)
- 1 3
- 1 2 3 4
- 1 3 5
- 2 4
7. Which loop is guaranteed to execute at least once in Python?
- for loop
- while loop
- do-while loop
- None of the above
8. What does the else clause with a for loop do in Python?
- Executes if loop encounters error
- Executes if loop completes normally
- Always executes
- Never executes
9. How to create an infinite loop in Python?
- while 1:
- while True:
- for i in infinite:
- Both 1 and 2
10. What is the output of: for char in "Python": print(char, end=" ")
- P y t h o n
- Python
- P y t h o n
- P,y,t,h,o,n