Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 3: Robust Change (5 points) Complete following function according to th

ID: 3724050 • Letter: Q

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 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")

Explanation / Answer

#this is only the function, it assumes the exceptions are already defined.Please provide exception classes if you want to see output def change(a,d): c={} if not isinstance(a,int) or not isinstance(d,list) or isinstance(a,bool): raise ChangeParameterError elif not all(d[i]
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote