loops and iterables in python

loops and iterables in python

University

20 Qs

quiz-placeholder

Similar activities

Lists In Python_1

Lists In Python_1

9th Grade - University

15 Qs

Python Lists

Python Lists

University

20 Qs

COMP177 Mod 8 - Lists & Dictionaries

COMP177 Mod 8 - Lists & Dictionaries

University

16 Qs

DSA Quiz 2

DSA Quiz 2

University

18 Qs

list 6th

list 6th

7th Grade - University

20 Qs

1212 Midterm Review

1212 Midterm Review

University

20 Qs

Quiz on List and Tuples

Quiz on List and Tuples

University

16 Qs

Week 7 Quiz

Week 7 Quiz

University

15 Qs

loops and iterables in python

loops and iterables in python

Assessment

Quiz

Computers

University

Medium

Created by

Prince Kumar

Used 1+ times

FREE Resource

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

for i in range(3):

print(i)

1 2 3

0 1 2

0 1 2 3

1 2 3 4

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What function creates an iterator for a given object?

iter()

next()

iterator()

loop()

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the break statement?

To stop the iteration and exit the loop

To skip the current iteration

To pause the iteration

To restart the loop

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

for i in range(2, 5):

print(i, end=" ")

1 2 3 4

2 3 4

2 3 4 5

1 2 3 4 5

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a mutable data type in Python?

String

Tuple

List

Set

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code print?

list1 = [1, 2, 3, 4, 5]

print(list1[1:4])

[1, 2, 3]

[2, 3, 4]

[2, 3, 4, 5]

[1, 2, 3, 4]

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you iterate over a dictionary?

for key, value in dict.items():

for key, value in dict.values():

for value in dict.keys():

for item in dict:

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?