Twa kɔ nsɛm atitiriw so
Log in
Sign up for FREE
arrow_back
Laabri

Loops Test

star
star
star
star
star
Last updated over 2 years ago
20 Nsɛmmisa
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
Asemmisa {{asɛmmisaAhyɛnsode}}
1.

What is output by the code below?

w = 20

while w < 60:

w += w // 2

print(w)

Asemmisa {{asɛmmisaAhyɛnsode}}
2.

What is output by the code below?

r = 1

while( r < 50 ):

r *= 3

print(r)

Asemmisa {{asɛmmisaAhyɛnsode}}
3.

What is output by the code below?

word = "the paintings"

cnt = 0

for letter in word:

cnt += 1

print(cnt)

Asemmisa {{asɛmmisaAhyɛnsode}}
4.

What is output by the code below?

for x in range(3):

print("Hi", end = " " )

Asemmisa {{asɛmmisaAhyɛnsode}}
5.

What is output by the code below?

for x in range(10):

print(x, end = " " )

Asemmisa {{asɛmmisaAhyɛnsode}}
6.

What is output by the code below?

m = 5

while( m > 0 ):

m -= 3

print("dog")

Asemmisa {{asɛmmisaAhyɛnsode}}
7.

What is output by the code below?

j = 0

while( j < 6 ):

j += 4

print(j)

Asemmisa {{asɛmmisaAhyɛnsode}}
8.

What is output by the code below?

for i in range (5):

print(i, end = " " )

Asemmisa {{asɛmmisaAhyɛnsode}}
9.

What is output by the code below?

num = 50

while num > 0:

if num > 20:

num -= 10

else:

num -= 15

print(num, end = " " )

Asemmisa {{asɛmmisaAhyɛnsode}}
10.

What is output by the code below?

for x in range 2:

print("light", end = " " )

Asemmisa {{asɛmmisaAhyɛnsode}}
11.

What is output by the code below?

i = 4

cnt = 0

while i < 80:

i *= i

print(cnt)

Asemmisa {{asɛmmisaAhyɛnsode}}
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

Asemmisa {{asɛmmisaAhyɛnsode}}
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

Asemmisa {{asɛmmisaAhyɛnsode}}
14.

What is output by the code below?

sum = 0

for t in range(2, 6):

sum += t

print(sum)

Asemmisa {{asɛmmisaAhyɛnsode}}
15.

What is output by the code below?

for num in range(8, 12):

if num // 10 == 1:

print(num, end = " " )

Asemmisa {{asɛmmisaAhyɛnsode}}
16.

What is output by the code below?

for i in range(4):

for j in range(3):

print(i + j, end = " " )

Asemmisa {{asɛmmisaAhyɛnsode}}
17.

What is output by the code below?

for i in range(2,5):

for j in range(3, 6):

print(j, end = " " )

Asemmisa {{asɛmmisaAhyɛnsode}}
18.

What is output by the code below?

word = "superhero"

for let in word:

if let != "h":

print(let, end = " " )

else:

break

Asemmisa {{asɛmmisaAhyɛnsode}}
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

Asemmisa {{asɛmmisaAhyɛnsode}}
20.

What is output by the code below?

s = 0

while s = 10:

s = s + 4

print(s)