KnowledgeBoat Logo
|

Informatics Practices

Consider the following dictionary and write the answers of the following:

DAYS={"day1": "Sunday", "day2": "Monday", "day3":"Tuesday", 'day5':" Thursday"}

(a) Add 'Wednesday' to the dictionary DAYS as a key 'day4'.

(b) Remove 'day5' item from the dictionary.

(c) Given the Dictionary metal, what is the output generated by the following code:

metal={"first":"gold", "second":"silver", "first":"copper"}
print(metal)

Python Dictionaries

2 Likes

Answer

(a)

DAYS['day4'] = 'Wednesday'

(b)

del DAYS['day5']

(c)

Output
{'first': 'copper', 'second': 'silver'}

Answered By

1 Like


Related Questions