Question: python question Complete following function according to the specification in the documentation string. You will need to create your own custom exceptions for these functions.
python question

Complete following function according to the specification in the documentation string. You will need to create your own custom exceptions for these functions. # Write your answers here. Define Change ParameterError 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 Change ParameterError 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
Get step-by-step solutions from verified subject matter experts
