Question: PYTHON 2.7 It is important to be familiar with the functions of dictionary: items(), keys0), values0, write a program to use all these functions. Notes:
PYTHON 2.7
It is important to be familiar with the functions of dictionary: items(), keys0), values0, write a program to use all these functions. Notes: Dictionary has two ways to initialize data dict0) datal'school] 'SChoolname' al'address'] = ,1000 School Avenue, Location, State 11111, data['phone'] ="(123) 789-0123 data = { 'school': 'SChoo!name', 'address','1000 School Avenue, Location, State 111 1 1', 'phone': '(123) 789-0123') Print the results as follows by accessing the defined dictionary. school: SChoolname . phone: (123) 789-0123 Task 5: Data Serialization Use json to store above dictionary in task-5 and then print item, key and values. Notes: This task tells how to store a dictionary object to a file and then load the dictionary object from the file. In python, object of any type can be mostly saved in json format to a txt file. You need to be familiar with the following two json functions json.dumps(object), which dumps an ob- ject to a json format (string), json.loads(a json format string), which loads a json format string back to the original object. We do not care about if the original object is list, dictionary or others. json.dumps() can automatically recognize. Note, json.load(object) only can only load an object, not a file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
