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]
2 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]2 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
T F The exit function can only be called from main .
ElenaW [278]

Answer:

FALSE

Explanation:

The exit function is used to terminate or halt the process.

Syntax-

            void exit(int status)  

Exit function (exit()) can be used in any function not only main() and it will terminate your whole process.

<u></u>

<u>Example-</u> C Program

#include<stdio.h>

#include <stdlib.h>  

//  function declaration

float exitexample ( float x );                                

// Driver program

int main( )                

{

 float a, b ;

 printf ( "\nEnter some number for finding square \n");

  scanf ( "%f", &a ) ;

 // function call

 b = exitexample ( a ) ;                      

 printf ( "\nSquare of the given number %f is %f",a,b );  

/*This will not printed as exit function is in exitexample() function*/

}

float exitexample ( float x )   // function definition  

{

 exit(0);    //exit function

   float p ;

  p = x * x ;

return ( p ) ;

}

5 0
3 years ago
All spreadsheet formula should start with
inysia [295]
A formula in Excel will ALWAYS start with = then the function name like
=SUM(A1:A5)
5 0
3 years ago
When a number gets assigned to a variable that already has a value __________?
Aleksandr-060686 [28]
A already assigned variable cannot be assigned twice You can make the variable change over to a new one or call a whole new one to assign one without a value or It might be possible to do v=n (v is variable and n is number / value)
3 0
3 years ago
Propose a data structure that supports the stack push and pop operations and a third operation findMin, which returns the smalle
juin [17]

Answer: attached below

Explanation:

3 0
3 years ago
Which of the following should you do if you are exhibiting your photographs?
Naddika [18.5K]

I would go with option a

hope that helped

3 0
3 years ago
Other questions:
  • Disk scheduling algorithms in operating systems consider only seek distances, because Select one: a. modern disks do not disclos
    13·1 answer
  • The analog signals that carry analog or digital data comprise composites built from combinations of simple sine waves.
    12·1 answer
  • Buenas , ayudenme con esta tarea de excel 2016
    6·1 answer
  • Supports traditional transactional processing for day-to-day front-office operations or systems that deal directly with the cust
    11·1 answer
  • Will give brainliest!!<br> (Question 3)
    12·2 answers
  • Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a
    8·1 answer
  • What is the positional weigh of the digit 7 in the octal number 7642 ?​
    15·1 answer
  • How can I make [ print(3 * x) ] into a functional python code?
    8·1 answer
  • Generally speaking, what is a “best practice"?
    13·1 answer
  • You have been on the phone with a user in a remote office for 30 minutes troubleshooting their minor desktop problem. No matter
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!