1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
astraxan [27]
3 years ago
12

Write a program that keeps track of a simple inventory for a store. While there are still items left in the inventory, ask the u

ser how many items they would like to buy. Then print out how many are left in inventory after the purchase. You should use a while loop for this problem. A sample run is below.
(CodeHS, PYTHON)
Computers and Technology
2 answers:
neonofarm [45]3 years ago
4 0

Answer:

STARTING_ITEMS_IN_INVENTORY = 20

num_items = STARTING_ITEMS_IN_INVENTORY

# Enter your code here

while num_items > 0:

print("We have " + str(num_items) + " items in inventory")

toBuy = int(input("How many would you like to buy?"))

if toBuy > num_items:

print("There is not enough in inventory")

print("Now we have " + str(num_items) + " left")

else: # ok to sell

num_items = num_items - toBuy # update

if num_items > 0: # only for printing

print("Now we have " + str(num_items) + " left")

print("All out!")

Explanation:

This allows Python to store the number of items in inventory after each purchase by subtracting how much is bought with the toBuy function by how much is left. This continues until num_items is no longer greater than zero. If what’s toBuy goes above the # of items left in inventory, then the “if toBuy > num_items” segment of the code comes into play by telling the user there’s not enough and re telling them how much is left and how much they’d like to buy. When the items in inventory is out, meaning the exact amount that’s left is purchased, then Python prints “All out!”

MissTica3 years ago
3 0

Answer:no

Explanation:

You might be interested in
Objects of the calculator class require no additional information when created. define an object named calc, of type calculator.
Grace [21]

Answer

calculator calc;

Explanation

An object is an instance of a class. And a class is what defines or describes the behavior or the state of the object of its type. When a class is defined no memory is allocated until when an object is created memory is allocated.

4 0
3 years ago
Read 2 more answers
Two devices that may be used for creating,storing,and transmitting documents input devices
castortr0y [4]

Answer:

electronic notebook or a pc?

Explanation:

sorry if its wrong of doesnt help

6 0
3 years ago
The amount of memory used by an array depends upon the array's data type and the number of elements in the array. True False
OverLord2011 [107]

Answer:

True

Explanation:

6 0
2 years ago
In general, the pilot and _______ approaches are the most favored conversion approaches.
Karo-lina-s [1.5K]

Answer:

The correct approach is "Phased".

Explanation:

  • The pilot step requires just to validate the development's implementation goals and objectives and then when the SDMX objects were introduced to development, several perhaps all problems have indeed been detected as well as logged through so that they're being corrected either by the detailed technical advisory committee.
  • The staggered or phased approach towards deployment provides the time possible to obtain the very next knowledge on evaluation criteria, staff including diverse cultures such that the strategy produced could be customized accordingly.
6 0
3 years ago
Which best compares appointments and events in Outlook 2010
lesantik [10]

In Microsoft Outlook, there are differences between appointment and event. Appointment is defined as <em>an activity that you schedule in your calendar which does not involve other people.</em> Appointments can be scheduled to a certain duration in a day. Event is defined as <em>an activity that you do with other people which lasts from 24 hours to longer. </em>

Thus, from these descriptions, the best answer to the question is (C) appointments have a start and end time of day, and events do not.

5 0
3 years ago
Other questions:
  • An example of hardware is a _____. database spreadsheet monitor program used to enhance photos
    13·2 answers
  • Instructions:Select the correct answer.
    13·1 answer
  • This provides an easy method for workers to use their computers.
    11·2 answers
  • using C++ to sort user input. for example, user enter 25numbers and sort them from small to big or big to small, cout thesamlles
    6·1 answer
  • What is the safest way to install a new flash drive
    7·2 answers
  • To create a cover letter to send to potential employers along with a resume, what software program should you use ?
    6·2 answers
  • Is there a relationship between cybercrime and traditional crime?
    6·1 answer
  • Determine which Software Type on the right best corresponds to each Definition on the left. Then, click the Definition, and then
    8·1 answer
  • Instructions: Write a program that calculates the amount of ingredients needed for various flavors of cheesecake.
    13·1 answer
  • You can use a(n) ______________to store large amounts of customer data for a website.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!