निम्नलिखित कोड का परिणाम क्या है ?
What is the output of the following code ?
a = {1: "A", 2: "B", 3: "C"}
b = {4: "D", 5: "E"}
a.update(b)
print(a)
A)
B)
C)
D)
Explanation:
Sure!
The update()
method adds all key-value pairs from dictionary b
to dictionary a
.
So, a
becomes {1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E'}
.
Answer: (B) {1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E'}.