Question 1:Find the output of the following program:
Python3
D = dict ()
for x in enumerate ( range ( 2 )):
D [ x [ 0 ]] = x [ 1 ]
D [ x [ 1 ] + 7 ] = x [ 0 ]
print ( D )
Question 2:Find the output of the following program:
Python3
D = { 1 : 1 , 2 : '2' , '1' : 1 , '2' : 3 }
D [ '1' ] = 2
print ( D [ D [ D [ str ( D [ 1 ])]]])
Question 3:Find the output of the following program:
Python3
D = { 1 : { 'A' : { 1 : "A" }, 2 : "B" }, 3 : "C" , 'B' : "D" , "D" : 'E' }
print ( D [ D [ D [ 1 ][ 2 ]]], end = " " )
print ( D [ D [ 1 ][ "A" ][ 2 ]])
Question 4:Find the output of the following program:
Python3
D = dict ()
for i in range ( 3 ):
for j in range ( 2 ):
D [ i ] = j
print ( D )
{0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}
TypeError: Immutable object
Question 5:Find the output of the following program:
Python3
D = { 1 : [ 1 , 2 , 3 ], 2 : ( 4 , 6 , 8 )}
D [ 1 ] . append ( 4 )
print ( D [ 1 ], end = " " )
L = [ D [ 2 ]]
L . append ( 10 )
D [ 2 ] = tuple ( L )
print ( D [ 2 ])
[1, 2, 3, 4] ((4, 6, 8), 10)
[1, 2, 3, 4] (4, 6, 8, 10)
[1, 2, 3, 4] TypeError: tuples are immutable
[1, 2, 3, 4] [4, 6, 8, 10]
Question 6:Find the output of the following program:
Python3
a = { i : i * i for i in range ( 6 )}
print ( a )
Dictionary comprehension doesn’t exist
{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6:36}
{0: 0, 1: 1, 4: 4, 9: 9, 16: 16, 25: 25}
{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
Question 7:Find the output of the following program:
Python3
a = {}
a . fromkeys ([ 'a' , 'b' , 'c' , 'd' ], 98 )
print ( a )
{‘a’:98, ‘b’:98, ‘c’:98, ‘d’:98}
{‘a’:None, ‘b’:None, ‘c’:None.’d’:None}
Question 8:Find the output of the following program:
Python3
dict = {}
print ( all ( dict ))
Question 9:Find the output of the following program:
Python3
a = { 'geeks' : 1 , 'gfg' : 2 }
b = { 'geeks' : 2 , 'gfg' : 1 }
print ( a == b )
Question 10:Find the output of the following program:
Which of these about a dictionary is false?
The values of a dictionary can be accessed using keys
The keys of a dictionary can be accessed using values
Dictionaries may or may not be ordered
"This course is very well structured and easy to learn. Anyone with zero experience of data science, python or ML can learn from this. This course makes things so easy that anybody can learn on their own. It's helping me a lot. Thanks for creating such a great course."- Ayushi Jain | Placed at Microsoft Now's your chance to unlock high-earning job opportunities as a Data Scientist ! Join our Complete Machine Learning & Data Science Program and get a 360-degree learning experience mentored by industry experts. Get hands on practice with 40+ Industry Projects, regular doubt solving sessions , and much more. Register for the Program today!
There are 25 questions to complete.
Last Updated :
Take a part in the ongoing discussion View All Discussion