CBSE Class 11 Computer Science Question 84 of 112

Dictionaries — Question 6

Back to all questions
6
Question

Question 6

What is the output produced by the following code :

d1 = {5 : [6, 7, 8], "a" : (1, 2, 3)}  
print(d1.keys())  
print(d1.values())  
Answer
Output
dict_keys([5, 'a'])  
dict_values([[6, 7, 8], (1, 2, 3)])  
Explanation

keys() function returns all the keys defined in the dictionary in the form of a list. values() function returns all the values defined in the dictionary in the form of a list.