The program creates two dictionaries, d1 and d2. d1 contains two key-value pairs, and d2 contains two key-value pairs as well. A new dictionary, res, is created using the copy method on d1, which creates a shallow copy of d1. The update method is then used on res to merge the key-value pairs from d2 into res.
Finally, the resulting dictionary res is printed. In summary, the program demonstrates how to merge two dictionaries in Python using the update method and the copy method to create a shallow copy of a dictionary.
d1={"Name":"Ram" , "Age":23} d2={"City": "Salem", "Gender": "Male"} res = d1.copy() res.update(d2) print(res)
{'Name': 'Ram', 'Age': 23, 'City': 'Salem', 'Gender': 'Male'}
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions