Loading

Quipoin Menu

Learn • Practice • Grow

Direction: Choose the correct option

Q1.

Which keyword is used to start a for loop?
A. loop
B. while
C. for
D. repeat
Direction: Choose the correct option

Q2.

What will be the output of `for i in range(3): print(i)`?
A. 0 1 2
B. 1 2 3
C. 1 2
D. 0 1 2 3
Direction: Choose the correct option

Q3.

What does `range(5, 10)` produce?
A. 5,6,7,8
B. 5,6,7,8,9
C. 5,6,7,8,9,10
D. 6,7,8,9
Direction: Choose the correct option

Q4.

How do you iterate over a list with indices?
A. Both A and B
B. `for i in range(len(list))`
C. `for i, item in enumerate(list)`
D. `for item in list`
Direction: Choose the correct option

Q5.

What is the output of `for i in []: print(i)`?
A. Error
B. Nothing
C. 0
Direction: Choose the correct option

Q6.

Which statement is used to skip the current iteration in a loop?
A. pass
B. break
C. continue
D. skip
Direction: Choose the correct option

Q7.

What does `break` do in a loop?
A. Restarts the loop
B. Exits the loop
C. Skips the iteration
D. Pauses the loop
Direction: Choose the correct option

Q8.

What is the correct way to write a while loop that runs 5 times?
A. Both A and B
B. i = 0; while i < 5: ...; i += 1
C. while i in range(5): ...
D. for i in range(5): ...
Direction: Choose the correct option

Q9.

What is the output of `i=0; while i<3: print(i); i+=1`?
A. 1 2 3
B. 0 1 2
C. 0 1 2 3
D. 0 0 0
Direction: Choose the correct option

Q10.

Which of the following is a valid infinite loop?
A. if True:
B. while True:
C. for i in range(10):
D. while 1: Both A and D