Python For Loops Quiz

Python For Loops Quiz

12th Grade

8 Qs

quiz-placeholder

Similar activities

Computer Science

Computer Science

9th - 12th Grade

12 Qs

Java String class methods

Java String class methods

10th - 12th Grade

10 Qs

Unity C# Beginner's Variables Quiz

Unity C# Beginner's Variables Quiz

12th Grade

8 Qs

Target Clear Game - Part 1

Target Clear Game - Part 1

12th Grade

10 Qs

Java

Java

9th - 12th Grade

12 Qs

PPS MCQ on 22.11.2024

PPS MCQ on 22.11.2024

10th Grade - University

6 Qs

VB Quiz

VB Quiz

5th Grade - University

10 Qs

🔦 Formative Assessment 2: Flow Controls

🔦 Formative Assessment 2: Flow Controls

12th Grade

10 Qs

Python For Loops Quiz

Python For Loops Quiz

Assessment

Quiz

Computers

12th Grade

Medium

Created by

Haden Hiser

Used 1+ times

FREE Resource

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a for loop in Python?

To define a function

To create a class

To iterate over a sequence

To handle exceptions

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is NOT a valid iterable in a for loop?

Integer

Dictionary

Tuple

List

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? fruits = ["apple", "banana", "cherry"] for x in fruits: if x == "banana": break print(x)

banana

apple cherry

apple

apple banana

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the range() function do in a for loop?

Returns a sequence of numbers

Returns a list of strings

Returns a dictionary

Returns a set of tuples

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? for x in range(2, 6): print(x)

3 4 5 6

0 1 2 3 4 5

2 3 4 5 6

2 3 4 5

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the continue statement in a for loop?

To skip the current iteration and continue with the next

To stop the loop

To exit the loop

To repeat the current iteration

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? for x in range(6): if x == 3: break print(x) else: print("Finally finished!")

0 1 2

0 1 2 3

0 1 2 3 Finally finished!

0 1 2 Finally finished!

8.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a nested loop?

A loop with a continue statement

A loop with a break statement

A loop inside another loop

A loop with an else statement