Complete the PA7_incomplete.py program (posted below) for an infinite interactive loop to process a dictionary. The program starts by asking an input file name where the dictionary entries are stored....


Complete the PA7_incomplete.py program (posted below) for an infinite interactive loop to process a dictionary. The program starts by asking an input file name where the dictionary entries are stored. This file will be assumed be present and to contain two items in each line as key and value pairs separated by a comma, like the example.txt file (posted below). The file could be possibly empty. The program reads the contents of this file into a dictionary, closes the file and presents user with the following menu choices in an infinite loop:



  • Add an entry

  • Show value for a key

  • Delete an entry

  • Save the file

  • Print the current dictionary

  • Quit

  • Complete rest of the program to process the dictionary interactively with the user. The following appropriate actions should be taken for each one of them and then the menu should be shown again unless the user quits.

    • Add an entry:Ask the user for the key and value, and make an entry, if the key already exists then prompt the user whether to overwrite its value.

    • Show value for a key: Ask the user for the key and show the corresponding value, point out if the key does not exist.

    • Delete an entry: Ask the user for the key and delete the entry, point out if the key does not exist

    • Save the file: Save to the same file name in the same comma-separated format (do not worry about the order of entries), make sure to close the file

    • Print the current dictionary: show value entries of the current dictionary on the screen (in alphabetical order of the keys).

    • End the program. If the dictionary has been modified since the last save, then prompt the user whether it should be saved before quitting.



Oct 28, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here