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
Does learning swift is hard? more than android?
ladessa [460]
No it is not. it's quite simple when you get the hang of it
4 0
3 years ago
Write a repetition statement that outputs the numbers 45 , 51 , . . . , 165 . That is, all of the multiples of 6 in increasing o
Bingel [31]

Answer:

#include <iostream>

using namespace std;

int main()

{

   int i = 45;

   for ( i = 45; i <=165; i = i + 6)

       cout << i << endl;

}

Explanation:

I corrected your code and highlighted the mistakes. Even though you wrote the correct algorithm, your code did not compile because of the typos you made.

Remember, C++ is a case-sensitive language. That means, "For" is not same as "for".

Generally, variables and keywords are written in lower case. Of course, there are exceptions, such as constant variables are all written in uppercase letter and class names start with an uppercase letter.

8 0
3 years ago
Write a program that prompts the user to enter the center and a point on the circle. The program should then output the circle’s
sergij07 [2.7K]

Here is the code in C++.

#include <bits/stdc++.h>

using namespace std;

// function to calculate distance between two points

double distance(int a,int b,int c,int d )

{

 // return the distance between center and point

  return sqrt(pow(c - a, 2) +

               pow(d - b, 2) * 1.0);

}

// driver function

int main()

{

// variables to store coordinates

int x1,y1,x2,y2;

cout<<"Please Enter the center(x y) of the circle: ";

//reading center

cin>>x1>>y1;

cout<<"\nPlease Enter a point(x1 y1) on the circle:";

//reading point

cin>>x2>>y2;

// calling distance() function with 4 parameters

double rad=distance(x1,y1,x2,y2);

// calculating Radius and print

cout<<"Radius of circle is: "<<rad<<endl;

// calculating Diameter and print

cout<<"Diameter of circle is: "<<2*rad<<endl;

// calculating Circumference and print

cout<<"Circumference of circle is: "<<2*3.14*rad<<endl;

// calculating Area and print

cout<<"Area of circle is: "<<3.14*rad*rad<<endl;

return 0;

}

Explanation:

First it will read coordinates of center and point on the circle.The distancebetween center and point on circle is Radius. Call distance() function withfour parameters which are coordinates of center and point. This will return the value of Radius. Diameter is 2 times of Radius.Diameter of a circle is 2*3.14*Radius. and Area of the circle is calculate as 3.14*Radius*Radius. After finding these value print them.

Output:

Please Enter the center(x y) of the circle: 0 0

Please Enter a point(x1 y1) on the circle: 3 4

Radius of circle is: 5

Diameter of circle is: 10

Circumference of circle is: 31.4

Area of circle is: 78.5

4 0
3 years ago
Write an if/else statement that compares the value of the variables soldYesterday and soldToday, and based upon that comparison
jenyasd209 [6]

Answer:

if(soldYesterday > soldToday){

salesTrend = -1;

} else if(soldToday > soldYesterday){

salesTrend = 1;

}

Explanation:

The if/else statement is more explicit. The first if condition check if soldYesterday is greater than soldToday, if true, then -1 is assigned to salesTrend.

Else if soldToday is greater than soldYesterday, if true, then 1 is assigned to salesTrend.

7 0
3 years ago
When a business is using methods that help it use its time and resources the best they can, what are they exercising?
maria [59]
<span>B. Efficiency

(</span><span>effective training </span><span>techniques)</span>
3 0
3 years ago
Read 2 more answers
Other questions:
  • True or false the primary advantage of the worksheet is the ability to solve numerical problems quickly and accurately
    11·1 answer
  • Which device lets you hear audio on your computer?
    12·2 answers
  • Write a memo to the vice president, outlining the steps an employee might have taken to create an e-mail message and make it app
    15·1 answer
  • “Green Technology” is also known as what?
    11·1 answer
  • At an open or uncontrolled intersection, yield if ____.
    15·2 answers
  • In Windows Vista, which button is used to create a new folder?
    7·1 answer
  • I am doing 7th grade coding 3.02 assignment can anybody help me it says bad input on line 3 and this is what it is can someone h
    6·1 answer
  • What<br>are<br>the features of secondary storage media​
    13·2 answers
  • Difference between academic library and school Library
    5·1 answer
  • Most file managers include a way to create a folder through the save dialog box. true or false?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!