Question: PYTHON PROGRAMMING 14)Suppose that a cashier in Canada owes a customer some change and that the cashier only has coins ie. toonies, loonies, quarters, dimes,

PYTHON PROGRAMMING

14)Suppose that a cashier in Canada owes a customer some change and that the cashier only has coins ie. toonies, loonies, quarters, dimes, and nickels. Write a function that determines the minimum number of coins that the cashier can return. In particular, write a function min_CAD_coins(price,payment) that returns five numbers (t,l,q,d,n) that represent the smallest number of coins (toonies, loonies, quarters, dimes, and nickels) that add up to the amount owed to the customer (here price and payment are defined as in the previous question). You program must first call cad_cashier function, from question 13, to determine the amount of change that needs to be returned. Then before doing anything else, you may want to convert this amount entirely to cents (that should be of type int). Once you have the total number of cents here are some hints on how to find the minimum number of coins.

code for question 13 :

def cad_cashier(price,payment): price=round(price/5,2)*5 return round(payment-price,2)

>>> # testing Question 14

>>> >>> min_CAD_coins(10.58,11)

(0, 0, 1, 1, 1)

>>> min_CAD_coins(98.87,100)

(0, 1, 0, 1, 1)

>>> min_CAD_coins(10.58,15)

(2, 0, 1, 1, 1)

>>> min_CAD_coins(10.55,15)

(2, 0, 1, 2, 0)

>>> min_CAD_coins(10.54,15)

(2, 0, 1, 2, 0)

>>> min_CAD_coins(10.52,15)

(2, 0, 2, 0, 0)

>>> min_CAD_coins(10.50,15)

(2, 0, 2, 0, 0)

>>> min_CAD_coins(3, 20)

(8, 1, 0, 0, 0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!