Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help me code this in python. Create a module named dict_io, which will contain two functions. These two function will save and load a dict
Help me code this in python.
Create a module named "dict_io", which will contain two functions. These two function will save and load a dict of integers in a text file. In this dictionary, both keys and values are integers. The format of the file is up to you, only make sure that the load function can load what the save function has saved. 1. [2.5p] Implement function save_dict, which takes two arguments - a dict of integers and a file path, and will store the dict under given path. 2. [1p] In function save_dict, if the file under given path already exists, save the data under a different path, prepending 'new_' to the base of the file name (i.e. '/foo/bar/file.txt' '/foo/barew_file.txt'). You do not need to check whether the new path exists. 3. [2.5p] Implement function load_dict, which takes a single argument, a file path, and returns a dict loaded. If the file does not exist, return an empty dictStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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