Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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}

Task 10 (5 points)

Write a Python script that will calculate the change due, if any, for a given payment and for a random cost, based on a given string 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 and it should loop continuously until the user enters "quit.

Input string

Expected output of script

Cost is 17.61

Enter a payment: 15.25

Enter a list of coin values: 1, .35, .23, .12, .03, .01

Cost is 7.88

Enter a payment: 20.00

Enter a list of coin values: 1, .35, .23, .12, .03, .01

Cost is 45.25

Enter a payment: quit

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

change: 12 1 coins, 1 .12 coins,

Goodbye!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions

Question

Evaluate three pros and three cons of e-prescribing

Answered: 1 week ago