Python Programming - Variables - Discussion
Discussion Forum : Variables - General Questions (Q.No. 31)
31.
What is the output of the following code:
my_dict = {"a": 1, "b": 2}
my_dict["c"] = 3
print(my_dict)
Answer: Option
Explanation:
In this code, a dictionary my_dict
is defined with two key-value pairs.
The second line adds a new key "c"
with the value 3
to the dictionary.
When the modified dictionary is printed to the console, the output is {"a": 1, "b": 2, "c": 3}
.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers