Search Header Logo

KP4-Loops

Authored by MrsT Voci

Arts

2nd Grade

Used 5+ times

KP4-Loops
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 SELECT QUESTION

45 sec • 1 pt

What would be the lowest value printed by this code?

for i in range(12):

print(i)

12

0

None of these

1

2.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

What is the value of the variable 'a' after it passes through the loops?

a = 0

for i in range(2):

for j in range(4):

a += i * j

10

4

6

8

3.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

What is the value of the variable 'a' after it passes through the loops?

a = 0

for i in range(2):

for j in range(3):

a += i + j

8

9

10

3

4.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

***Add the line of code needed to accumulate the total of all values of a and then print the result.

total=0

for a in range(6):

#what goes here?

print(total)

total = total +a

total = a +1

total += a

total =+a

5.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

****You are given a function which contains a non working while loop. The function also accepts a positive integer (x). The while loop is in an infinite loop state, which would be unwise to run. The while loop continually decreases the value variable by 1. Your task is to fix the code so that the loop exits and returns the value variable when it is equal to x.

def while_loop_finisher:

value = -1

while value:

value -=1

if value == x:

return x

break

if value == 1:

return value

break

if value = x:

return x

break

if x == value:

return x

break

6.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

What is the purpose of the break statement in Python?

Skip the remainder of the if body and transfer control to the if condition

Terminate the loop and transfer control to the statement following the loop

Skip the remainder of the loop body and transfer control to the loop condition

Terminate the if statement and transfer control to the statement following the if

7.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

What does the “continue” Statement in Python do?

it terminates the execution of statements while iterating the loop

it breaks the loop

None of these

it does not break the loop

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?