Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 3 CODE required Complete following function according to the specification in the documentation string. You will need to create your own custom exceptions for

image text in transcribedPYTHON 3 CODE required

Complete following function according to the specification in the documentation string. You will need to create your own custom exceptions for these [ ]: # Write your answers here. Define ChangeParameterError and ChangeRemainderError in this code cell as well. def changel(a, d): Computes the change of amount a given denominations d Parameter a must be of type int, d must be of type list of int, and the elements of d must be in ascending order, otherwise ChangeParameterError is raised The result is a dictionary with keys from d, mapping to values of the number of coins bills of each denomination. This is computed by first taking the maximal number of coins bill of the highest denomination, then the next highest, etc. If no exact change is possible, ChangeRemainderError is raised return [ ]: change ( 3, [3, 7)) {3: 1, 7: 0} == [ ]: change(15, [1, 3, 7)) {1: 1, 3: 0, 7: 2} == try change (True, [4]) # raises ChangeParameterError except ChangeParameterError: print("Successful test case") try change (3, 7) # raises ChangeParameterError except ChangeParameterError: print("Successful test case") try change ( 3 , [ 7 , True ] ) # raises ChangeParameterError except ChangeParameterError: print("Successful test case") try change ( 3 , [ 7 , 3 ] ) # raises ChangeParameterError except ChangeParameterError: print("Successful test case") try change ( 3 , [ 2 , 7 ] ) # raises ChangeRemainderError except ChangeRemainderError: print("Successful test case")

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_2

Step: 3

blur-text-image_3

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago