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

Create a two functions: first called grocery_cost(food), where food can be one item or a list of items from the stock and price

dictionaries, the second is called stock_check(stock_list) where a store manager can check if stock numbers are at a minimum value.grocery_cost: loops through the argument food, notes the price, checks the stock, calculates and prints the total cost and changes the stock number. You will need to use a for statement to loop through the items in food and an if statement to check and update the stock (substract one from the stock for each item in the stock).Stock_check: loops through each item in the stock dictionary and uses an if-statement to print a statement if stock is less than 5.Given:stock_key={'tomato soup':20,'cheese':10,'milk':25,'oreos':100,'red bull':0,'apples':17,'oranges':4}price_key={'tomato soup':1.85,'cheese':3.99,'milk':4,'oreos':7.49,'red bull':0.99,'apples':0.59,'oranges':1.29}
Computers and Technology
1 answer:
Elena L [17]3 years ago
6 0

Answer:

stock_key={'tomato soup':20,'cheese':10,'milk':25,'oreos':100,'red bull':0,'apples':17,'oranges':4}

price_key={'tomato soup':1.85,'cheese':3.99,'milk':4,'oreos':7.49,'red bull':0.99,'apples':0.59,'oranges':1.29}

def grocery_cost(*args):

   total_cost = 0

   for arg in args:

       if arg in stock_key.keys():

           stock_key[arg] -= 1

           total_cost += price_key[arg]

   print( f"Total cost of groceries: {total_cost}")

def stock_check():

   for key, value in stock_key.items():

       if value < 5:

          print(f"The stock \"{key}\" is less than 5.")

grocery_cost('apples', 'oranges','milk', 'oreos','cheese')

stock_check()

Explanation:

The functions of grocery_cost and stock_check are python defined functions. The former accepts a list of one or more items and calculates the total cost of the grocery items from the stock and price dictionary while the latter check the size of the stock in the food store.

You might be interested in
​the complete definition of a database, including descriptions of all fields, tables, and relationships, is called a _____.
SOVA2 [1]
A rational database is a one consisting of more than one table. It includes all fields of description and its relationships. 
7 0
4 years ago
Give a recursive algorithm to compute the sum of the cubes of the first n positive integers. The input to the algorithm is a pos
DaniilM [7]

Answer:

def sum_cubes(n):

   if n == 1:

       return 1

   else:

       return n * n * n + sum_cubes(n-1)

print(sum_cubes(3))

Explanation:

Create a function called sum_cubes that takes one parameter, n

If n is equal to 1, return 1. Otherwise, calculate the cube of n, and add it to the sum_cubes function with parameter n-1

If we want to calculate the cubes of the first 3 numbers:

sum_cubes(3) = 3*3*3 + sum_cubes(2)

sum_cubes(2) = 2*2*2 + sum_cubes(1)

sum_cubes(1) = 1

If you substitute the values from the bottom, you get 27+8+1 = 36

7 0
3 years ago
The term that describes the connection of all kinds of devices; computers, phones, laptops, appliances, cars, etc. to the intern
Kryger [21]
This is hyped as the Internet of Things (IoT). Sometimes also called IoE, the Internet of Everything.
4 0
3 years ago
Develop a multithreaded app that can find the integer in the range 1 to 10000 that has the largest number of divisors. It should
skelet666 [1.2K]

Answer:

its not letting me Write out the code so here are screenshots

Explanation:

5 0
4 years ago
That agreement received after completing it to your program at a community college is called a
Zanzabum

Answer :  Articulation Agreement.

Explanation :

Articulation is a general contract between some colleges and universities which allows a student to easily go to another university for more education. It is a formal agreement between two parties documenting the transfer policies for some specific programs or academic courses.

The articulation agreement is given only when the program is completed at the community college with good behaviour and academic record. The argument documents a pathway between two colleges or universities and their academic programs.

3 0
3 years ago
Other questions:
  • If you were asked to subnet a network in such a way as to arrive at 6 network ids you would need to borrow 2 bits.
    7·1 answer
  • "If a VM is given exclusive access to hardware devices on the host computer, what new Windows Server 2016 feature is being utili
    14·1 answer
  • When is the bond between the actin and myosin head is broken? when an ATP molecule binds to the myosin head when an ATP molecule
    6·1 answer
  • What is microsoft access?
    14·1 answer
  • Instructions:Select the correct answer.
    6·2 answers
  • Match the file extensions to the file types. Some file types may be used more than once.
    11·1 answer
  • When you start a new blank document, you begin typing at the
    6·1 answer
  • Programs for embedded devices are often written in assembly language. Some embedded processors have limited instructions, like M
    5·1 answer
  • The National Vulnerability Database (NVD) is responsible for actively performing vulnerability testing for every company's softw
    8·1 answer
  • if you put a drone on the charger at 8:12 and take a break at 10:03 how long is it on the charger. for
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!