Question: Python. 1. Write a script called that repeatedly asks the user to first enter a price and then a number of items for that price.

Python.

1. Write a script called that repeatedly asks the user to first enter a price and then a number of items for that price. At any point, the user can type in done (case insensitive) to indicate that they are finished entering items, and the script should display the total cost and the total number of items. It should keeps track of the item numbers.

Example:

Python. 1. Write a script called that repeatedly asks the user to

2. Improve the script so that it handles situations where the user enters in something other than a number (or the word done) without crashing or ending the whole thing early. It can't crash and it can't just give up entirely when the user enters in non-numeric data.

RESTART At any time, you may type 'done' to finish. What is the c st f Item #1? 1.50 How many of item #1 are you buying? What is the c st f item #2? How many of item #2 are you buying? 10 What is the c st f item #3? done You have purchased 12 items , at a tta1 c stf $33.0 RESTART At any time, you may type 'done' to finish What is the c st f item #1? 1.99 How many of item #1 are you buying? >100 What is the c st of item #2? >7.01 How many of item #2 are you buying? >DONE You have purchased 100 items , at a total cst f $199.0 RESTART At any time, you may type 'done' to finish What is the c st f item #1? >Done You have purchased 0 items, at a total cost of $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!