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
Phantasy [73]
3 years ago
11

Create a new file that builds a shopping list from a user. There should be a input query that asks the user to list an item and

the number of those items. Two lists should be built that reflects the items on the list and the number of each items that are to be purchased. The list should build until the user is done. b. Call up your function grocery_cost to check the stock and build your total cost. Your program should let the user know if the items they want are in stock. If there is not enough stock, your program should let the user know that and offer them the number that are in stock. You will need to edit your grocery_cost function to reflect that a number of items will be selected instead of just one. c. Call up your stock_check function and print items that need restocking

Computers and Technology
1 answer:
levacccp [35]3 years ago
7 0

Answer:

Check the output

Explanation:

# -*- coding: utf-8 -*-

"""

Created on Thu Apr 12 00:39:11 2018

author:

"""

stocks ={

       "tomato soup": 20,

       "cheese": 8,

       "bread": 6,

       "milk": 8,

       "butter": 7,

       "coffee": 8,

       "ice cream": 5,

       "orange juice": 12,

       "bacon": 6,

       "tortilla chips": 14,

       "ramen": 24 }

prices ={

       "tomato soup": 1.85,

       "cheese": 3.99,

       "bread": 2.50,

       "milk": 3.59,

       "butter": 1.99,

       "coffee": 5.99,

       "ice cream": 2.99,

       "orange juice": 2.50,

       "bacon": 5.49,

       "tortilla chips": 3.00,

       "ramen": 0.99 }

def grocery_cost(item_list,quantity_list):

   totalcost = 0

   for i in range(len(item_list)):

       totalcost=totalcost+(quantity_list[i]*prices[item_list[i]])

       

   return totalcost

def stock(item):

   print("Number of itmes present in the stock:",stocks[item])

print("Welcome to the on-line grocery store!!")

print("Items that are available for purchase:")

for key in stocks.keys():

   print(key)

#chosen foods

print("Enter the item with quantity or Enter 'Q' when you are done")

item_list=[]

quantity_list=[]

while True:

   item=input('Enter the item name: ')

   if item=='Q' or item=='q':

       break

   item_list.append(item)

   while True:

       quan=int(input('Enter the number of item: '))

       if stocks[item] >=quan:

           quantity_list.append(quan)

           break

       else:

           stock(item)

           print('Your requirement is higher than stock available. Please enter again!!')

print("\nTotal cost:", "$",grocery_cost(item_list,quantity_list))

Kindly check the output in the attached image below.

You might be interested in
If you need to multiply 400, 2, and 1 ½, what would you type on the numeric keypad?
balandron [24]
You will type

400*2*1.5

1.5 is another way to say 1 1/2
4 0
3 years ago
Read 2 more answers
A(n) _____ identifies how you feel about an activity or subject. computer calculator interest inventory both b and c
Alexeev081 [22]

Answer:

Interest

Explanation:

3 0
3 years ago
Read 2 more answers
Based on the description below which website is more appropriate
I am Lyosha [343]

Answer:

D

Explanation:

8 0
3 years ago
Read 2 more answers
Review the HTML tags that we have gone over in this lesson. Research HTML tags on the web and identify two new tags. Use these t
NemiM [27]

Answer:

w3schools

Explanation:

there is a webiste called w3schools that really helped me through my web page design class, just click on learn html

4 0
3 years ago
Which item converts a high level language program to low level machine instruction?
vodomira [7]
The compiler translates each source code instruction into the appropriate machine language instruction, an
8 0
3 years ago
Other questions:
  • The sum of all the minterms of a boolean function of n variables is equal to 1.
    7·1 answer
  • Why is it important to verify a customer complaint?
    6·1 answer
  • What is batch processing?
    12·1 answer
  • Among the following, which is the best protection against ransomware?
    8·1 answer
  • The spreadsheet ends after you reach column Z and row 99. True or false
    12·1 answer
  • The Mark Table of Contents Entry option is used for marking nonheading text for the table of contents. the options are manually
    5·2 answers
  • If a fire should break out in your building, which of the following actions is NOT recommended?
    10·2 answers
  • Que significa el término Informática?
    6·1 answer
  • ____ Is an Internet service that allows users to send and receive short text messages In real time.
    10·1 answer
  • When a program is adapted to run on multiple processors in a multiprocessor system, the execution time on each processor is comp
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!