Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python In this assignment you will extend the dictionary' class by adding a new subclass and four methods. The new class should be called 'NewDict'

Python image text in transcribed
In this assignment you will extend the dictionary' class by adding a new subclass and four methods. The new class should be called 'NewDict' and must be a subclass of dict". The new methods will provide functions that are not directly included in the basic dictionary class. They are: displaysorted)- displays the contents of the dictionary in ascending key order addfromlist0-adds the contents of a list to the dictionary using the first list element as the key and the rest as the value retrieve0- returns the list of values using the keys provided in a list of keys merge0-merges in the contents of an input dictionary resulting in a new dictionary containing the original plus the input Specification requirements for each method are in the table below. Method Name displaysorted Purpose Input Depending on the value of an input D- display D display list R-Return listR return list parameter, displays the contents of the dictionary in ascending key-sorted order, Bdo both returns a list consisting of the key and values in sorted order, or does both. If the parameter is not D, R, or B assume the default ofD B display and list return Default-D addfromlist Adds the content of an input list to the Input list dictionary using the first list element as key and the remainder of the list as the key value. Validate that the input is a type list If the input is not a list, return False' and the message 'not a list If input is a list, return True'and the new Retrieve the dictionary values using anList of keys input list consisting of keys to be looked up in the dictionary. Return a list consisting of the key and its corresponding value. Ifa key is not in the dictionary, return the character string not found'. Validate that the input is type 'list If the input is not a list, returm 'False and not a list If input is a list, return True' and a list consisting of the keys and values. If a key is not in the dictionary, the key and 'not found retriev Merges an input dictionary into the current/ self dictionary. Validate that the merged in input is the correct type. Return 'False and 'not a dictionary' if it isn't. If a key in the input dictionary is already in self, add the key to a dupes list. When done, return True and the list of merge Dictionary to be If input is not a dictionary, return False' and invalid input' message. If input is a dictionary, return True and the list of duplicates

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

What are the purposes of promotion ?

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago