wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Day 2

Total questions: 10

Worksheet time: 2mins

Name
Class
Date
1.

Which of the following data types in Python is mutable?

a)

String

b)

Tuple

c)

List

d)

Dictionary

2.

What will be the output of the following code?

my_tuple = (1, 2, 3)

my_tuple[0] = 4

print(my_tuple)

a)

(1, 2, 3)

b)

(4, 2, 3)

c)

Error: Tuple indices must be integers, not strings

d)

Error: Tuple object does not support item assignment

3.

Which data type in Python is used to store a collection of elements with no duplicate values?

a)

Set

b)

List

c)

Tuple

d)

Dictionary

4.

Which of the following is NOT a valid way to create a dictionary in Python?

a)

my_dict = {}

b)

my_dict = dict()

c)

my_dict = {1: 'one', 2: 'two', 3: 'three'}

d)

my_dict = {'one': 1, 'two': 2, 'three': 3}

5.

What is the result of the expression: len("Hello World")?

a)

5

b)

10

c)

11

d)

12

6.

Which of the following data types in Python allows duplicate elements?

a)

List

b)

Tuple

c)

Set

d)

Dictionary

7.

What will be the type of the following expression: type((1,2))?

a)

List

b)

Tuple

c)

Set

d)

str

8.

What will be the output of the following code?

x = 10

if x > 5:

    print("x is greater than 5")

else:

    print("x is less than or equal to 5")

a)

x is greater than 5

b)

x is less than or equal to 5

c)

x is equal to 5

9.

What will be the output of the following code?

for i in range(3):

    print(i)

a)

012

b)

111

c)

000

d)

123

10.

What is the purpose of the else clause in a loop

a)

It executes when a loop is terminated prematurely using break.

b)

It executes when a loop condition becomes False

c)

It executes if an exception is raised inside the loop

d)

 It executes after each iteration of the loop