Search Header Logo

Quiz 3

Authored by Wai Li

Information Technology (IT)

University

Quiz 3
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

12 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 mins • 1 pt

What is the output of the following code?

for i in range(3):

print(i)

1 2 3
0 1 2
0 1 2 3
Error

2.

MULTIPLE CHOICE QUESTION

30 mins • 1 pt

What does the break statement do in a loop?

Pauses the loop
Repeats the loop
Exits the loop immediately
Skips one iteration

3.

MULTIPLE CHOICE QUESTION

30 mins • 1 pt

How many times will this loop run?

i = 0

while i < 3:

print(i)

i += 1

2
3
4
Infinite

4.

MULTIPLE CHOICE QUESTION

30 mins • 1 pt

Which of the following will create an infinite loop?

for i in range(5):
while True:
while i < 10: with i +=1
for i in range(0, -1):

5.

MULTIPLE CHOICE QUESTION

30 mins • 1 pt

Media Image

(0, 0), (1, 1)
(0, 0), (0, 1), (1, 0), (1, 1)
(2, 2)
Error

6.

MULTIPLE CHOICE QUESTION

30 mins • 1 pt

What is the correct way to loop 5 times using a while loop?

while 5:
for i in 5:
i = 0; while i < 5: i += 1
while i ==5:

7.

MULTIPLE CHOICE QUESTION

30 mins • 1 pt

Which loop will execute the body at least once, even if the condition is false initially?

for loop
while loop
Neither - Python has no do-while
Both

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?