Question: Python language on Jupyter notebook Exercise 2 Define a function called money that accepts two parameters: a currency amount: a float denoms: an option tuple

Python language on Jupyter notebook
Exercise 2 Define a function called money that accepts two parameters: a currency amount: a float denoms: an option tuple of denomination values, for example, (0.01, 0.05, 0.10) represents pennies, nickles and dimes in ascending order. The default value should be (0.01, 0.05, 0.10, 0.25, 1.0, 5.0, 10.0) Your function should calculate how many of each denomination is required in order to sum to the supplied currency amount. For example: money(0.37, denom=(0.01, 0.05, 0.10)) returns (2, 1, 3) because 3 0.10 + 1 = 0.05 + 2 * 0.01 = 0.37. In this case, the function tells us how many pennies, nickles and dimes are required to form 37 cents. As close as possible. money(1.28, denom=10.01, 0.05, 0.10,0.25, 1.0, 5.0)) yields [3,0,0,1, 1, 0] which implies 3 pennies, 1 quarter, and 1 dollar bill. Hint: sort the denomination tuple in descending order (largest denomination first). then consider each denomination value in turn calculate how many times (count) that denomination value can divide your money amount then calculate how much money remains for the other denominations, repeat this over and over for each possible denomination collecting your counts into a list. Make sure your function returns the final list in the proper order. See example cases above. [ ]: # your function definition here [ ]: # your tests here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
