Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python Task 4: Data Structure It is important to be familiar with the functions of dictionary: items(), keys(), values(), write a program to use all
Python
Task 4: Data Structure It is important to be familiar with the functions of dictionary: items(), keys(), values(), write a program to use all these functions Notes: Dictionary has two ways to initialize data - dict() datal'schoolj = UAlbany, datal'address']- '1400 Washington Ave, Albany, NY 12222' data[Phone'] "(518) 442-3300, data = {'school': 'UAlbany,, 'address: ,1400 Washington Ave, Albany, NY 12222, phone: ,(518) 442-3300'} Print the results as follows by accessing the defined dictionary. school: UAlbany address: 1400 Washington Ave, Albany, NY 12222 phone: (518) 442-3300 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 Task 6: Data Serialization Store a number of different types objects (e.g., list, dictionary, array) to a file and then load the objects from the file Write a function to dump list object items = [1,2,3,4,5] and above dictionary in task-o to a file called 'task6.data', and then load them from the same file and printStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started