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

11. Which function is used to get both index and value in a loop?

  • index()
  • enumerate()
  • range()
  • iter()
Show Answer Report

12. What will this code output: x = 5 while x > 0: print(x) x -= 1

  • 5 4 3 2 1
  • 5 4 3 2 1 0
  • 4 3 2 1 0
  • Infinite loop
Show Answer Report

13. Which statement is used to skip the rest of the code in the current iteration?

  • break
  • skip
  • continue
  • pass
Show Answer Report

14. What is the purpose of the pass statement in loops?

  • Exit the loop
  • Skip iteration
  • Do nothing placeholder
  • Pause execution
Show Answer Report

15. How to iterate over two lists simultaneously in Python?

  • Using parallel()
  • Using zip()
  • Using merge()
  • Using combine()
Show Answer Report

16. What is the output of: for i in range(2): print(i, end=" ") else: print("Done")

  • 0 1 Done
  • 0 1
  • Done
  • 0 1 else: print("Done")
Show Answer Report

17. Which loop is more suitable when the number of iterations is unknown?

  • for loop
  • while loop
  • nested loop
  • infinite loop
Show Answer Report

18. What does range(4) generate?

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

19. How to iterate over dictionary keys in Python?

  • for key in dict:
  • for key in dict.keys():
  • for key in dict.items():
  • Both 1 and 2
Show Answer Report

20. What is nested loop in Python?

  • Loop inside another loop
  • Loop with multiple conditions
  • Loop with break statement
  • Loop with continue statement
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test