Loops Questions and Answers

Take Exam

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
Show Answer Report

2. What is the output of: for i in range(3): print(i)

  • 0 1 2
  • 1 2 3
  • 0 1 2 3
  • 1 2
Show Answer Report

3. Which keyword is used to exit a loop prematurely in Python?

  • exit
  • stop
  • break
  • return
Show Answer Report

4. What does the continue statement do in a Python loop?

  • Exits the entire loop
  • Skips current iteration
  • Restarts the loop
  • Pauses the loop
Show Answer Report

5. How many times will this loop execute: while False: print("Hello")

  • 0 times
  • 1 time
  • Infinite times
  • 2 times
Show Answer Report

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
Show Answer Report

7. Which loop is guaranteed to execute at least once in Python?

  • for loop
  • while loop
  • do-while loop
  • None of the above
Show Answer Report

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
Show Answer Report

9. How to create an infinite loop in Python?

  • while 1:
  • while True:
  • for i in infinite:
  • Both 1 and 2
Show Answer Report

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
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test