Question: Task 06 (5 points) Write a Python script that uses a function to test a given input value and return whether it is enough to

Task 06 (5 points)

Write a Python script that uses a function to test a given input value and return whether it is enough to cover a purchase of $14.85. Your script should take in the amount due as an argument and continually prompt the user to enter their payment. The function should compare the payment to the cost, print whether it is over or under and by how much, and if it is too much it should then return the difference.

Input string

Expected output of script

Enter a number: 12.89

Enter a number: 14.85

Enter a number: 25.13

That is not enough by 1.96

That is exactly enough

There is change due of 10.28

Task 07 (5 points)

Write a Python script that uses a function to return the amount of change made from a given value based on the following table of coin values:

0

1

2

3

4

5

1

.35

.23

.12

.03

.01

The function should take in the change due as an argument and return a dictionary of the coin values.

Input string

Expected output of script

Enter a value: 9.76

{'1 coin': 9, '.35 coin': 2, '.23 coin': 0, '.12 coin': 0, '.03 coin': 2, '.01 coin': 0}

Task 08 (5 points)

Write a Python script that will calculate the change due, if any, for a given payment if the total cost is $16.48, based on the following table of coin values. If the payment is made with exact change, no change will be due. If the payment is over the total amount, then the output will be the change due. If the payment is under the total amount, the output will be how much more is needed. Your script should also provide input checking to ensure that only digits are being entered and are in the correct format before doing any calculations.

0

1

2

3

4

5

1

.35

.23

.12

.03

.01

Input string

Expected output of script

Enter your payment: 20.00

Enter your payment: 16.48

Enter your payment: 10.70

change: 3 1 coins, 1 .35 coins, 1 .12 coins, 1 .03 coins, 2 .01 coins,

No change due

needed: 5 1 coins, 2 .35 coins, 2 .03 coins, 2 .01 coins,

Task 09 (5 points)

Write a Python script that uses a function to return the amount of change made from a given string of coin values. The function should take in the change due as an argument and the list of currency values and return a dictionary of the coin values.

Input string

Expected output of script

Enter a value: 13.37

Enter coins: 1, .20, .10, .05, .01

{'1 coin': 13, '.20 coin': 1, '.10 coin': 1, '.05 coin': 1, '.01 coin': 2}

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!