Menu

Count Controlled Iteration (For Loops)

Card 1 of 16 0 got it 0 still learning
Question
TapClick or press space to see the answer
Answer
All 16 cards in this set
Which term describes repetition of a section of code?
Iteration
What is meant by a count-controlled loop?
A loop that repeats a section of code a set number of times
What is meant by the range in a for loop?
The set of values that the loop variable takes
Which term describes a value that tells a for loop how much to increase or decrease by each time?
Step
Which type of loop is designed to run a set number of times?
A count controlled loop such as a for loop
How many times does the loop body run in: for i in range(1, 8)?
7 times
Which numbers does this loop print: for i in range(1, 10, 2)?
1, 3, 5, 7, 9
Which numbers does this loop print: for i in range(10, 1, -1)?
10, 9, 8, 7, 6, 5, 4, 3, 2
What does a for loop do when it is used with a list?
It repeats once for each item in the list
Which loop correctly prints each score in the array scores?
for s in scores: print(s)
When would a for loop be a better choice than a while loop?
When the exact number of repetitions is known in advance
What is the purpose of the loop variable i in for i in range(5)?
It takes each value in the range in turn
Which numbers does this loop print: for i in range(4)?
0, 1, 2, 3
What does this program print?
10
Which loop correctly prints every item in the array testResults using the position of each item?
for i in range(len(testResults)): print(testResults[i])
What is meant by the body of a for loop?
The statements that are repeated by the loop