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

Needed ingredients for recipes Before making a dish, we want to check whether we already have the necessary ingredients in our p

antry or whether we need to go shopping. For this problem, you will implement a method needed_ingredients for the Pantry class. needed_ingredients takes a list of recipes as its argument and returns a new Pantry containing everything missing from our pantry to make all the recipes in the list. If our pantry already has all the necessary ingredients in the needed quantities, needed_ingredients returns an empty Pantry. There may be repeated recipes in the input list, and the input list may be empty. # You may wish to use defaultdict to implement needed_ingredients. from collections import defaultdict def needed_ingredients(self, recipes): "Given a list of recipes, computes which ingredients to buy, and in which quantity, to be able to make all recipes. Can be implemented in 10 lines of code."** #Code here raise Not ImplementedError()
Computers and Technology
1 answer:
almond37 [142]3 years ago
8 0

Answer:

See explaination

Explanation:

class Pantry(AD):

def __init__(self, ingredients):

""" We initialize the Pantry class by passing the ingredients that were passed

in to the initializer for the superclass AD"""

super().__init__(ingredients)

def needed_ingredients(self, recipes):

""" Given a list of recipes, computes which ingredients to buy, and in which

quantity to be able to make all recipes. Can be implemented in 10 lines of code."""

# define the object new_pantry to contain the ingredients needed

new_pantry = Pantry({})

ingredients_present = self

# loop over the recipes in the list

for recipe in recipes:

# convert ingredients of recipe from AD to Pantry

ingredients = Pantry(recipe.ingredients)

# subtract the recipe's ingredients from ingredients_present

ingredients_present = ingredients_present - ingredients

# loop over the ingredients_present

for key in ingredients_present:

# if any ingredients's quantity < 0, add it to new_pantry

if ingredients_present[key] < 0:

# check if ingredient is present in new_pantry, add the quantity to existing quantity

if key in new_pantry:

new_pantry[key] += -1*(ingredients_present[key])

else: # if ingredient is not present in new_pantry, make a new entry for the ingredient

new_pantry[key] = -1*(ingredients_present[key])

ingredients_present[key] = 0 # set the quantity of the ingredient in ingredients_present to 0

return new_pantry

You might be interested in
Write the pseudocode for this flowchart
MrMuchimi

Answer:

Explanation:

class TimeToSleep() {

  main bunch of stuff (string argos) {

       int age;

       string comedy;

       bool guess;

        public bool imTheMasterMethod() {

           guess = true;

           while (guess) {

              comedy = "You forgot to put the flowchart, you meathead!";

              println(comedy);

               

                scan("%d", &age);

                if (age < 18) {

                    println("Go to sleep kiddo!");

                }

           }

        }

   }

}

       

6 0
3 years ago
Which of the following statements is true of a cookie? a. A cookie can create copies of itself and spread to other networks to e
Ilya [14]

Answer: D.

Data about user preferences and activity is captured and stored under a cookie on a company’s Web server.

Explanation: The most common and best-known technology for user tracking is the use of cookies. Other known online website tracking tools are tracking pixels (or pixel tags), web beacons (or ultrasound beacons), and browser fingerprinting (or digital fingerprinting), amongst others.

a cookie will contain a string of text that contains information about the browser. To work, a cookie does not need to know where you are from, it only needs to remember your browser. Some Web sites do use cookies to store more personal information about you.

8 0
3 years ago
How can i repair computer processor?
Lisa [10]
Short answer, you don't. Modern Processors are made up of billions of transistors and are built in multi million dollar factories that have equipment just for that purpose.
8 0
4 years ago
Match the following: B. Static libraries A. Dynamic Link Libraries (DLL) - Using static libraries - Making some changes to DLL A
TiliK225 [7]

Answer:  hello your question is poorly written and I have been able to properly arrange them with the correct matching

answer

Static libraries :  C

Dynamic link libraries:  A

Using static libraries:  B

Making some changes to DLL:   D

Explanation:

Matching each term with its meaning

<u>Static Libraries </u> : Are attached to the application at the compile time using the Linker ( C )

<u>Dynamic link libraries</u> ( DLL ) : Is Loaded at runtime as applications need them ( A )

<u>Using static Libraries </u>: Makes your program files larger compared to using DLL ( B )

<u>Making some changes to DLL </u>: Does not require application using them to recompile ( D )

8 0
3 years ago
____ is a limited version of windows that allows you to use your mouse, screen, and keyboard but no other peripheral devices.
Gnoma [55]
'SAFEMODE' <span>is a limited version of windows that allows you to use your mouse, screen, and keyboard but no other peripheral devices.</span>
8 0
3 years ago
Other questions:
  • Suppose you're trying to remove the clamp from a ground strap that's connected to a battery. The clamp won't come loose. Which o
    14·2 answers
  • I need help making a survey for highschool students in my school any topics/questions?
    9·1 answer
  • The arithmetic logic unit (alu) controls all of the functions performed by the computer's other components and processes all the
    7·1 answer
  • A company is utilizing servers, data storage, data backup, and software development platforms over an Internet connection.
    14·1 answer
  • When planning a backup strategy, ideally one needs to prioritize important data and only back up what is absolutely necessary fo
    15·1 answer
  • Write a SELECT statement that selects all of the columns for the catalog view that returns information about foreign keys. How m
    6·1 answer
  • 8.13 LAB: Elements in a range Write a program that first gets a list of integers from input. That list is followed by two more i
    8·1 answer
  • What is the limitation of computer<br>​
    5·1 answer
  • Who Is faster sonic or flash well it all depends on which version of sonic your talking about like for example video game sonic,
    14·1 answer
  • When Alice turned on her laptop this morning, the screen displayed only colorful horizontal lines. Which of the following is mos
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!