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
Rachel works in a bank. She wants to present the idea of implementing an IS to the management. How should Rachel describe the IS
Leni [432]

Rachael should describe information system to the management as an organized system that helps collect or gather, organize, track, store, manipulate, and analyze data to generate and distribute the information from gathered data to appropriate persons. The information generated is useful for managing your operations and making decisions. The efficient use of Information Systems will, without a doubt give a lot of opportunities to the company.

6 0
3 years ago
Read 2 more answers
Judy forgot where she saved a certain file on her computer. Therefor, she searches for all files with a jpg file extension. Whic
Keith_Richards [23]
What are these files anyways
6 0
3 years ago
Read 2 more answers
Who is the first computer programmer​
enot [183]

Answer:

Ada Lovelace was the first computer programmer

8 0
2 years ago
Read 2 more answers
The definition of HTTP makes use of the ASCII character set without reference to how these characters are encoded. Explain why t
solniwko [45]
Abstraction comes from two latin words; abs which means away and trahere which mean to draw. From the meaning itself, it is to draw away something from specific objects, individuals, group, etc. In the computer world, a programmer hides all relevant data pertaining to the relevance of a data. It is done to increase efficiency and and reduce complexity. 
4 0
3 years ago
Read 2 more answers
The _____ feature will allow users to view nonprinting formatting marks to aid in editing a document. View Alignment Show/Hide I
Annette [7]

The __Show/Hide Insert___ feature will allow users to view non printing formatting marks to aid in editing a document.

The answer is D. Show/Hide Insert

Let me know if this is correct

5 0
3 years ago
Other questions:
  • Create a class named BaseballGame that contains data fields for two team names and scores for each team in each of nine innings.
    12·1 answer
  • Determine the number of bytes necessary to store an uncompressed binary image of size 4000 × 3000 pixels.
    9·1 answer
  • When ordering a new​ zagflatz, customers must choose the style of three major​ components, each of which has about ten variation
    6·1 answer
  • Mr. Perry has bookmarked a large number of webpages in Chrome while researching class topics. Unfortunately, he's bookmarked so
    13·1 answer
  • The algorithm ADDN implements N-bit fixed-width binary addition for non-negative integers and ignores overflows. For example, AD
    13·1 answer
  • Is a router on the local network that is used to deliver packets to a remote network?
    15·1 answer
  • What are some hazards of being an astronomer??
    6·1 answer
  • File:///media/fuse/drivefs-0142e6928396ed2afff070ead0fbbbcd/root/JerooLessonFourLabA_1.pdf
    6·1 answer
  • Please help with coding assignment.
    11·1 answer
  • Differentiate between patent and copyright.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!