stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Python Loops Flashcards | StudBud
Explore
/
Python Loops
Python Loops
20 terms
·
StudBud Administration
·
192 plays
A quiz on Python programming concepts taught in NC BP14 Python Programming I
Flashcards
20 cards
F
Practice quiz
P
Host live
L
Questions
20
Answers
1
How many times will the following loop iterate?
never
6
4
5
2
Which of these is
NOT
a valid Python loop?
If Loop
for x in range () loop
while Loop
For x in loop
3
What is
wrong
with this loop:
for x in range (10, 0, -1) :
There is a syntax error.
It is an infinite loop
Nothing
The loop is counting backwards.
4
How many times will this loop run?
for i in range( 10, 0, -1):
never
infinitely
10
11
5
How many times does this
for loop
run:
for x in range (1, 5)
5 times
4 times
6 times
Infinitely
6
How many times will the message be displayed?
once for each item in the list
infinitely
one time more than the number of items in the list.
never
7
How many times will the value of x be printed?
1
infinitely
5
Never
8
How many times will "
Even
" be displayed?
5 times
10 times
Never
4 times
9
If an incrementing statement read
i += 2
by how much would it increment?
It won't execute due to a syntax error
1
3
2
10
Each time through a loop is called a(n) ___________
interpretation
initialization
iteration
culmination
11
What should be in the blank:
while ___________ :
control value
end value
incrementing or decrementing statement
A Boolean expression or Boolean variable
12
What is the difference between a
while loop
and a f
or loop
?
Nothing. They are basically the same.
A while loop can only be used once in a while.
A while loop runs for a pre-determined number of times.
A for loop runs for a pre-determined number of times.
13
A while loop must contain what inside the loop?
a break statement
an input() statement
A loop counter
something to alter the value in the while statement, or a break statement
14
When does a while loop end?
When the program hits the last statement in the loop block.
When the boolean expression is no longer true.
When the boolean expression is true.
After it has gone through the loop 10 times.
15
How many times will the following loop iterate?
Never
5
10
100
16
When should you use a
For
loop?
The number of times the code needs to be repeated is known .
You don't have a specific number of repetitions in mind
You have used too many while loops in your program.
You want the loop to stop after the boolean is false.
17
Why are loops used?
In order to make your code look more complex.
In order to call another method.
In order to execute a block of code several times.
In order to make the program more professional.
18
How many times will the following loop execute?
Until the user enters "n"
infinitely
One time after the user enters "n"
never
19
What is a key difference between a
for
loop and a
while ... loop
?
Only a for loop can be used wtih lists.
a while loops executes for a predetermined number of times.
They are exactly the same.
A for loop executes for a determined number of times.
20
What is wrong with the following statement:
for x in range (0, 11, -1)
You can't have a step of -1.
x isn't a proper variable name.
There is a logic error. The loop is never started.
Nothing. It is correctly coded.