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
What is pressure?
Licemer1 [7]
"force per unit area" because pressure is force per unit area.

hope this helped
6 0
4 years ago
Read 2 more answers
In excel, a number can contain the characters__
KATRIN_1 [288]
Comma and period? You can have numbers like 123,456.78
7 0
3 years ago
HELP ME PLEASE!!!!!!!!!!!!
Mila [183]

Answer:

b b isss the right answer

5 0
3 years ago
Read 2 more answers
Identify way in which computer are used in personnel management
Lyrx [107]

The main roles of computer in human resource management are decreasing time complexity, flexibility, record keeping problem etc. HRM system process lots of data everyday with the help of computer. This data processed easily without any fear of data loss so computer a vital role in human resource management system. The usage of computer in human resource management can be usually referred to as management information system. It can also be called as human resource information system. Usually what a computer does, it converts all the data or we can say raw data into meaningful and usable information required by the manager to take decisions, and for planning and control.

please I need brainliest thanks

I hope this helps

4 0
3 years ago
Read 2 more answers
Based on the chart below, which pie flavors make up approximately one-half of the total? A pie chart shows the following pie fla
Vladimir [108]
Based on the data, a combination of strawberry rhubarb (12%), chocolate mud pie (23%) and cherry (14%) would amount to 49% which is close to half of the pie chart or 50%. Another probable answer is the combination of coconut (9%), banana cream (10%), pumpkin (11%), and other (21%) which is equal to 51%.
8 0
4 years ago
Read 2 more answers
Other questions:
  • Which of the following are examples of algorithms? (Select all that apply, if any do.)
    15·2 answers
  • On a network, which protocol is responsible for dividing files into chunks, adding headers containing information for reassembli
    10·1 answer
  • What will be displayed if the following Java code segment is run? System.out.println("one "); System.out.print("two "); System.o
    12·1 answer
  • Elsa wants to save her work at the office to be continued at home either on a pen drive or CD. Outline three reasons why she wil
    6·1 answer
  • The function of anOR gate can best be described as a gate which provides an output of 1 only when
    10·1 answer
  • If i hit the delete key three times what will be left
    12·1 answer
  • What is the volume of a rectangular prism with a length of 812 centimeters, width of 913 centimeters, and a height of 1225 centi
    12·1 answer
  • What will be the value of x after the following loop terminates?
    13·1 answer
  • What keyword is used in Java to create a parent/child relationship between two classes?
    14·1 answer
  • Have the javascript function CountingMinutes(str) take the str parameter being passed which will be two times (each properly for
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!