Preskoči na glavni sadržaj
Prijava
Sign up for FREE
arrow_back
Biblioteka

Loops Test

star
star
star
star
star
Posljednje ažuriranje about 2 years ago
20
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
Pitanje 1
1.

What is output by the code below?

w = 20

while w < 60:

w += w // 2

print(w)

Pitanje 2
2.

What is output by the code below?

r = 1

while( r < 50 ):

r *= 3

print(r)

Pitanje 3
3.

What is output by the code below?

word = "the paintings"

cnt = 0

for letter in word:

cnt += 1

print(cnt)

Pitanje 4
4.

What is output by the code below?

for x in range(3):

print("Hi", end = " " )

Pitanje 5
5.

What is output by the code below?

for x in range(10):

print(x, end = " " )

Pitanje 6
6.

What is output by the code below?

m = 5

while( m > 0 ):

m -= 3

print("dog")

Pitanje 7
7.

What is output by the code below?

j = 0

while( j < 6 ):

j += 4

print(j)

Pitanje 8
8.

What is output by the code below?

for i in range (5):

print(i, end = " " )

Pitanje 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 = " " )

Pitanje 10
10.

What is output by the code below?

for x in range 2:

print("light", end = " " )

Pitanje 11
11.

What is output by the code below?

i = 4

cnt = 0

while i < 80:

i *= i

print(cnt)

Pitanje 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

Pitanje 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

Pitanje 14
14.

What is output by the code below?

sum = 0

for t in range(2, 6):

sum += t

print(sum)

Pitanje 15
15.

What is output by the code below?

for num in range(8, 12):

if num // 10 == 1:

print(num, end = " " )

Pitanje 16
16.

What is output by the code below?

for i in range(4):

for j in range(3):

print(i + j, end = " " )

Pitanje 17
17.

What is output by the code below?

for i in range(2,5):

for j in range(3, 6):

print(j, end = " " )

Pitanje 18
18.

What is output by the code below?

word = "superhero"

for let in word:

if let != "h":

print(let, end = " " )

else:

break

Pitanje 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

Pitanje 20
20.

What is output by the code below?

s = 0

while s = 10:

s = s + 4

print(s)