wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Lesson 43 - Dictionary Datatype 1

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following is not true ?

a)

set can have a element multiple times.

b)

tuple is mutable

c)

dictionary is set of key value pair

d)

All of the above

2.

Which of the following way is used to add elements to the dictionary ?

a)

a['1']=30

b)

a['22.5']=40

c)

a['rohit']=25

d)

All of the above

3.

which of the following statement is true ?

a)

Dictionary can have same value multiple times with unique keys

b)

Dictionary can have same key multiple times with unique values

c)

Dictionary is immutable in nature

d)

none

4.

a={'rohit': 70, 'rahul': 100, 'rohan': 80}

From above dictioary 100 can be accessed by -

a)

a['rahul']

b)

a['1']

c)

a['rahul'] and a.get("rahul")

d)

none

5.

What will be the output of following code ?

x={'rohit': 20, 'rahul': 25, 'rohan': 30}

for i in x:

print(i)

a)

rohit

rahul

rohan

b)

20

25

30

c)

rohit:20

rahul:25

rohan:30

d)

none

6.

What will be the output of the following code -

x={'rohit': 20, 'rahul': 25, 'rohan': 30}

for i in x.values():

print(i)

a)

rohit

rahul

rohan

b)

20

25

30

c)

rohit 20

rahul 25

rohan 30

d)

none

7.

What will be the output of the following code ?

x={'rohit': 20, 'rahul': 25, 'rohan': 30}

for x, y in x.items():

print(x, y)

a)

rohit

rahul

rohan

b)

20

25

30

c)

rohit 20

rahul 25

rohan 30

d)

none

8.

What will be the output of the following code ?

x="rohit"

y=list(x)

for i in range(len(x)):y[i]=x[(i+3)%len(x)]

s=""

for i in y:s+=i

print(s)

a)

tihor

b)

rohit

c)

itroh

d)

roiht

9.

An empty set can be created by which of the following ways ?

a)

s={}

b)

s=set()

c)

s=()

d)

s=[]

10.

What will be the output of the following code ?

a={"rohit":70,"rahul":75,"rounak":80}

print(a["notchup"])

a)

key error

b)

syntax error

c)

value error

d)

none