Answered step by step
Verified Expert Solution
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
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 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
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