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
11. Which function is used to get both index and value in a loop?
- index()
- enumerate()
- range()
- iter()
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
13. Which statement is used to skip the rest of the code in the current iteration?
- break
- skip
- continue
- pass
14. What is the purpose of the pass statement in loops?
- Exit the loop
- Skip iteration
- Do nothing placeholder
- Pause execution
15. How to iterate over two lists simultaneously in Python?
- Using parallel()
- Using zip()
- Using merge()
- Using combine()
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")
17. Which loop is more suitable when the number of iterations is unknown?
- for loop
- while loop
- nested loop
- infinite loop
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
20. What is nested loop in Python?
- Loop inside another loop
- Loop with multiple conditions
- Loop with break statement
- Loop with continue statement