Search Header Logo

6. Mastering Python Loops

Authored by Ramadhan Ramadhan

Other

11th Grade

6. Mastering Python Loops
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

21 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the syntax for a for loop in Python?

for variable in sequence:

for (variable : sequence)

for each variable in sequence:

for variable in sequence[]

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you iterate over a list using a for loop?

for item in my_list: print(item)

for item in my_list: item.print()

for item in range(len(my_list)): print(my_list[item])

for item in my_list: print(item, end='')

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code: for i in range(5): print(i)?

0 1 2 3 4

-1

10

5

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain the difference between a for loop and a while loop.

A for loop runs indefinitely, while a while loop stops after a set number of iterations.

A for loop iterates a known number of times, while a while loop continues until a condition is false.

A for loop is used for conditional statements, while a while loop is used for iteration.

A for loop requires a condition to be true, while a while loop does not need any condition.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the syntax for a while loop in Python?

do while condition:

repeat until condition:

for condition in iterable:

while condition: # code to execute

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How does a while loop terminate?

When the loop condition becomes false.

When the loop condition becomes true.

When the loop is manually stopped by the user.

When the loop runs for a set number of iterations.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code: count = 0; while count < 3: print(count); count += 1?

3

-1

1.5

0 1 2

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?