for loop quiz

for loop quiz

University

10 Qs

quiz-placeholder

Similar activities

Python-Grundlagen (IF Kl. 10)

Python-Grundlagen (IF Kl. 10)

10th Grade - University

15 Qs

basic programming quiz

basic programming quiz

University

10 Qs

Python Round 4

Python Round 4

University

7 Qs

Java Quiz based on array

Java Quiz based on array

University

15 Qs

Python Quiz

Python Quiz

University

12 Qs

Unit 2 Python

Unit 2 Python

University

10 Qs

CFDA Coding and Program Design Unit Review

CFDA Coding and Program Design Unit Review

9th Grade - University

15 Qs

Python_IOSC

Python_IOSC

University

15 Qs

for loop quiz

for loop quiz

Assessment

Quiz

Computers

University

Medium

Created by

thanga_palani_ thanga_palani_

Used 1+ times

FREE Resource

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

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?