Computer Science
Which of the following is correct with respect to above Python code ?
d = {"a" : 3,"b" : 7}
- a dictionary d is created.
- a and b are the keys of dictionary d.
- 3 and 7 are the values of dictionary d.
- All of these.
Python Dictionaries
1 Like
Answer
All of these.
Reason — The dictionary d has two key-value pairs where a and b are the keys and 3 and 7 are the values respectively. Therefore, all the statements are correct.
Answered By
3 Likes
Related Questions
A copy of the dictionary where only the copy of the keys is created for the new dictionary, is called …………… copy.
- key copy
- shallow copy
- deep copy
- partial copy
A copy of the dictionary where the copy of the keys as well as the values is created for the new dictionary, is called …………… copy.
- key copy
- shallow copy
- deep copy
- partial copy
What would the following code print ?
d = {'spring':'autumn','autumn':'fall','fall':'spring'} print(d['autumn'])- autumn
- fall
- spring
- Error
What is printed by the following statements ?
D1 = {"cat":12,"dog":6,"elephant":23,"bear":20} print("dog" in D1)- True
- False
- Error
- None