Question: Question 3: Robust Change (5 points) Complete following function according to the specification in the documentation string. You will need to create your own custom

Question 3: Robust Change (5 points) 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 ChangeParameterError and ChangeRemainderError in this code ceLL as well def change1(a, d): Computes the change of amount a given denominations d Paraneter a must be of type int, d must be of type 1ist of int, and the elenents of d must be in ascending order, otherwise ChangeParaneterError is raised The result is a dictionary with keys from d, mapping to values of the nunber of coins bills of each denomination This is conputed by first taking the maxinal number of coinsbill of the highest denomination, then the next highest, etc If no exact change is possible, ChangeRemainderError is raised. return change( 3, 13, 7]) {3: 1, 7: e} change( 15, 11, 3, 7)) (1: 1, 3: e, 7: 2} try change(True, [4]) # raises ChangeParameterError except ChangeParameterError: print("Successful test case") try change(3, 7) raises changeParameter-Error 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 ChangeRemainder-Error except ChangeRenainderError: 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
