Q. Predict the output of the following code:
birthday = { 'Newton' : 1642, 'Darwin' : 1809, 'Turing' : 1912 } print ('keys :', birthday.keys()) print ('values :', birthday.values()) print ('items:', birthday.items()) print ('get:', birthday.get('Curie', 1867)) temp = { 'Curie' : 1867, 'Hopper' : 1906, 'Franklin' : 1920 } birthday.update(temp) print ('after update:', birthday) birthday.clear() print ('after clear:', birthday)
Answer =
Output:-
keys : dict_keys(['Newton', 'Darwin', 'Turing']) values : dict_values([1642, 1809, 1912]) items: dict_items([('Newton', 1642), ('Darwin', 1809), ('Turing', 1912)]) get: 1867 after update: {'Newton': 1642, 'Darwin': 1809, 'Turing': 1912, 'Curie': 1867, 'Hopper': 1906, 'Franklin': 1920} after clear: {} >>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )