Log in
Sign up for FREE
arrow_back
Library
Loops Test
By Mickey Arnold
star
star
star
star
star
Share
share
Last updated almost 2 years ago
20 questions
Add this activity
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
Question 1
1.
What is output by the code below?
w = 20
while w < 60:
w += w // 2
print(w)
visibility
View drawing
Question 2
2.
What is output by the code below?
r = 1
while( r < 50 ):
r *= 3
print(r)
visibility
View drawing
Question 3
3.
What is output by the code below?
word = "the paintings"
cnt = 0
for letter in word:
cnt += 1
print(cnt)
visibility
View drawing
Question 4
4.
What is output by the code below?
for x in range(3):
print("Hi", end = " " )
visibility
View drawing
Question 5
5.
What is output by the code below?
for x in range(10):
print(x, end = " " )
visibility
View drawing
Question 6
6.
What is output by the code below?
m = 5
while( m > 0 ):
m -= 3
print("dog")
visibility
View drawing
Question 7
7.
What is output by the code below?
j = 0
while( j < 6 ):
j += 4
print(j)
visibility
View drawing
Question 8
8.
What is output by the code below?
for i in range (5):
print(i, end = " " )
visibility
View drawing
Question 9
9.
What is output by the code below?
num = 50
while num > 0:
if num > 20:
num -= 10
else:
num -= 15
print(num, end = " " )
visibility
View drawing
Question 10
10.
What is output by the code below?
for x in range 2:
print("light", end = " " )
visibility
View drawing
Question 11
11.
What is output by the code below?
i = 4
cnt = 0
while i < 80:
i *= i
print(cnt)
visibility
View drawing
Question 12
12.
What is output by the code below?
words = "math and science"
i = 0
for let in words:
if let == "n":
print(let)
break
i += 1
visibility
View drawing
Question 13
13.
Which of the following would correctly fill
/* code */
in method
cntEs()
?
#method
cntEs
should return the count of all e’s in words
def cntOdds(words):
cnt = 0
/* code */
return cnt
for let in words:
cnt += 1
if let == "e":
cnt += 1
for let in words:
if let == "e":
cnt = 1
for let in words:
if let == "e":
cnt += 2
for let in words:
if let == "e":
cnt += 1
Question 14
14.
What is output by the code below?
sum = 0
for t in range(2, 6):
sum += t
print(sum)
visibility
View drawing
Question 15
15.
What is output by the code below?
for num in range(8, 12):
if num // 10 == 1:
print(num, end = " " )
visibility
View drawing
Question 16
16.
What is output by the code below?
for i in range(4):
for j in range(3):
print(i + j, end = " " )
visibility
View drawing
Question 17
17.
What is output by the code below?
for i in range(2,5):
for j in range(3, 6):
print(j, end = " " )
visibility
View drawing
Question 18
18.
What is output by the code below?
word = "superhero"
for let in word:
if let != "h":
print(let, end = " " )
else:
break
s u p e r
superhero
s u p e r h e r o
h e r o
let
visibility
View drawing
Question 19
19.
What is output by the code below?
j = 2
word = "music notes"
for let in word:
if j % 2 == 0:
print(let, end = " " )
else:
print(j, end = " " )
j = j + 1
visibility
View drawing
Question 20
20.
What is output by the code below?
s = 0
while s = 10:
s = s + 4
print(s)
visibility
View drawing