Menu

Count-Controlled Iteration

Card 1 of 20 0 got it 0 still learning
Question
TapClick or press space to see the answer
Answer
All 20 cards in this set
What is meant by 'iteration'?
Repeating a set of instructions in a program
What is meant by 'nesting'?
Putting one loop inside another loop
Which term describes the amount by which the loop variable changes on each pass of a FOR loop?
Step
Which term describes the values that a FOR loop counts through, from the start value up to but not including the stop value?
Range
What is meant by 'loop variable'?
The variable that takes each value in turn as the loop repeats
What is meant by the loop body?
The instructions that are repeated each time the loop runs
What is meant by the stop value of a range?
The value the loop stops before using
What does a count-controlled loop do in a program?
It repeats instructions a set number of times
A program must display the numbers 1 to 20, including 20. Which range should the FOR loop use?
Use range(1, 21)
What is the last value of i in for i in range(10, -1, -1)?
0
Which loop repeats its body zero times?
A loop using range(10, 0)
A program uses a FOR loop to add up five scores into a running total. Where should total = 0 be placed?
Before the loop starts
An outer FOR loop runs 3 times and the inner loop runs 4 times. How many times does the code inside the inner loop run?
12
A program stores a number typed by the user in count. Which range makes the loop body run exactly count times?
Use range(0, count)
A loop must visit every position of a word stored in word. Which range should be used?
Use range(0, len(word))
Which task is best carried out with a count-controlled loop?
Printing the seven times table from 1 to 12
In a FOR loop, which values does range(10) give?
0 to 9
What does the last pass of this program print?
72
A program adds four scores, 5, 7, 9 and 11, into a running total inside a FOR loop. It then works out the average of the scores after the loop. What is the average?
8
In the loop for i in range(0, 10, 3), which values does the loop variable take?
0, 3, 6, 9