Definite Iteration
Computer Science Master
Question 1. What is definite iteration?
□ A. Iterating until a condition becomes false with an unknown number of loops □ B. Repeating a fixed number of times, such as looping through a list □ C. Repetitive execution with no condition to stop □ D. Running loops based on user input
Question 2. Which part of a for loop checks if the loop should continue or stop?
□ A. Initialization □ B. Update □ C. Condition □ D. Execution block
Question 3. In the Python range() function, what does the 'stop' parameter represent?
□ A. The number included in the sequence □ B. The first number generated by range() □ C. The number at which the sequence stops, but is not included □ D. The step size between numbers
Question 4. What is the default step value in the range() function if not specified?
□ A. 0 □ B. 1 □ C. 2 □ D. Undefined
Question 5. Consider the loop: for i in range(3): print(i). How many times will the print statement execute?
□ A. 2 □ B. 3 □ C. 4 □ D. 5
Question 6. Fill in the blank(s)
The three parts of a for loop include _____________________, _____________, and _________.
Question 7. Fill in the blank(s)
In Python's range() function, if you omit the start value, it defaults to _.
Question 8. Fill in the blank(s)
The stop value in range(start, stop, step) is _____________, meaning it is not included in the generated sequence.
Question 9. Fill in the blank(s)
In definite iteration, the loop runs a __________________ of times.
Question 10. Fill in the blank(s)
The default step size in the range() function is _ if not otherwise specified.
Question 11. Explain what happens during the 'update' phase of a for loop.
Question 12. Describe what the range(0, 10, 2) function call does.
Question 13. What does the for loop 'for i in range(5): print(i)' output?
Question 14. In the context of Python for loops, what type of object does the range() function return?
Question 15. Why does the loop terminate when using a range() function?
Question 16. Describe the process of definite iteration using a for loop in Python, including the role of initialization, condition, and update.
Question 17. Explain how the range() function works in Python and how it facilitates definite iteration within for loops.
Question 18. Discuss why understanding the exclusive nature of the 'stop' parameter in range() is important when writing for loops.