for loop quiz

for loop quiz

University

10 Qs

quiz-placeholder

Similar activities

Tutorium1

Tutorium1

University

10 Qs

Node.js

Node.js

University

10 Qs

WAN Sesi 1

WAN Sesi 1

1st Grade - University

10 Qs

GUESS THE ANSWER

GUESS THE ANSWER

University

10 Qs

Generalidades OBC

Generalidades OBC

University

15 Qs

Software Testing

Software Testing

University

10 Qs

C++ Array Quiz

C++ Array Quiz

University

10 Qs

Information System and Modern Organization part 1

Information System and Modern Organization part 1

University

14 Qs

for loop quiz

for loop quiz

Assessment

Quiz

Computers

University

Practice Problem

Medium

Created by

thanga_palani_ thanga_palani_

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does a for loop do?

Repeats a block of code

Skips a line

Runs code once

Stops the program

Answer explanation

For loop repeats code for each item or number

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output?

for i in range(3):

print(i)

1 2 3

0 1 2

0 1 2 3

1 2

Answer explanation

range(3) goes from 0 to 2

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

for i in range(1, 4) will print:

1 2 3

0 1 2

1 2 3 4

2 3 4

Answer explanation

Starts at 1, stops before 4

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which is the correct for loop syntax?

for i in range(5):

for i = 5

for i -> 5

for in range(5)

Answer explanation

Python uses for variable in range():

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does range(2, 10, 2) do?

2 to 10

2, 4, 6, 8

2, 4, 6, 8, 10

1, 2, 3, 4

Answer explanation

Step of 2 means it skips numbers

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output?

for ch in "hi":

print(ch)

hi

h i

i h

Error

Answer explanation

Loops over each character

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What data type works with a for loop?

Only numbers

Strings, lists, ranges

Only strings

Only booleans

Answer explanation

Can loop over anything that’s a sequence

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?

Discover more resources for Computers