Final Exam Reviewer
Final Exam Reviewer
Using Python
Final Exam Reviewer
A. 2
B. 3
C. 4
D. Infinite
Answer: B
25. Which of the following is NOT iterable in a for loop?
A. List
B. Tuple
C. Dictionary
D. Integer
Answer: D
26. What will be the output of the following code?
i=0
while i < 3:
print(i)
i += 1
A. 0 1 2
B. 1 2 3
C. 0 1 2 3
D. Infinite loop
Answer: A
27. What is the purpose of the break statement in loops?
A. Skip the current iteration
B. Stop the entire loop
C. Restart the loop
D. Jump to the next iteration
Answer: B
28. What will the following code output?
for i in range(5):
if i == 3:
continue
print(i)
A. 0 1 2 4
B. 0 1 2 3 4
C. 0 1 2
D. Infinite loop
Answer: A
29. What is the role of the else clause in loops?
A. Executes if the loop finishes normally
B. Executes after every iteration
C. Executes when the loop is infinite
D. Executes when the loop encounters a break
Answer: A
30. What is the output of the following code?
name = input("Enter your name: ")
print(f"Hello, {name}!")
A. Hello, name!
B. Enter your name:
C. Depends on user input
D. SyntaxError
Answer: C