Question

In: Computer Science

in python please! Couple of lists you need before we start baking material_list = ['onion', 'egg',...

in python please!

Couple of lists you need before we start baking

material_list = ['onion', 'egg', 'cucumber', 'eggplant', 'pasta', 'tomato','butter','rice','garlic','snail']

R_eggsouffle = ["egg", "milk", "butter"]
R_escargot = ["snail",'garlic','wine','butter']
R_FriedRice_v1 = ["onion", 'rice', 'egg']

We want to check if our material can make any of these recipes

Part A

The objective here is to make a function that checks

- if your ingredients can make eggsouffle, escargot, FriedRice_v1 or not

Basically, if we pass down the recipe name into a function, it should tell me whether we can make that recipe with the ingredients in material_list or not

- for example, if your function is Enough(R)
- if you pass Enough("FriedRice_v1"), the result will be yes, you can make FriedRice_v1
- but if you pass Enough("escargot"), the result will be no, you don't have enough ingredients

##### code here ######

Now Let's do the same thing using dictionary

First, let's make a dictionary with all the recipes inside

##### code here ######
 

Now, let's solve part A using dictionary

##### code here ######

Part B

Now Chef Robinson knows the exact quantities of the ingredients he has.

- 'onion' 150g , 'egg' 200g, 'cucumber' 300g, 'eggplant' 400g, 'pasta' 300g 
- 'tomato' 100g ,'butter' 420g ,'rice' 500g ,'garlic' 600g, 'snail' 2000g

Make a dictionary that tells Chef Robinson how much of each ingredients he has using tuples

##### student code here ######

Solutions

Expert Solution

The code for part A is:

ingredients = {} # storing in the dictionary
ingredients["material_list"] = ['onion', 'egg', 'cucumber', 'eggplant', 'pasta', 'tomato','butter','rice','garlic','snail']
ingredients["eggsouffle"] = ["egg", "milk", "butter"]
ingredients["escargot"] = ["snail",'garlic','wine','butter']
ingredients["FriedRice_v1"] = ["onion", 'rice', 'egg']

def Enough(recipe):
    if set(ingredients[recipe]).issubset(set(ingredients["material_list"])): # check if the list elements present in other list
        return 'yes' # first convert the list to set and then use subset to check if True or False
    return 'no'

print(Enough("FriedRice_v1"))
print(Enough("escargot")) 

The sample of the code is:

The output sample of the code is:

The code for part B is:

# storing the tuple
ingredient = (('onion', '150g') , ('egg', '200g'), ('cucumber', '300g'), ('eggplant', '400g'), ('pasta', '300g'), 
              ('tomato', '100g') , ('butter', '420g') , ('rice', '500g') , ('garlic', '600g'), ('snail', '2000g'))
quantity = dict(ingredient) # converting tuple of tuple to dictionary

# just for displaying and testing
for k, v in quantity.items(): # displaying the key value pairs
    print(k + ' : ' + v)

The sample of the code is:

The output sample of the code is:

I have hidden the file name due to the guidelines. If you have any queries regarding the above code comment down. I will help you out as soon as possible.


Related Solutions

Find a baking recipe that calls for baking soda but not baking powder (you many need...
Find a baking recipe that calls for baking soda but not baking powder (you many need to use the Internet as a reference for the recipe). Is there a source of acid in the recipe? If so, what is it? How could you modify the recipe if you had no baking soda at home? b). Find a baking recipe that calls for baking powder but not baking soda (you many need to use the Internet as a reference for the...
Before you start analysing the firm's financial statements, you will need to obtain industry averages for...
Before you start analysing the firm's financial statements, you will need to obtain industry averages for each of the standard financial statement ratios. They are provided below. 2019 2020 2021 Industry Averages Profitability Ratios Return on equity 21.3% 21.2% 19.6% 22.0% Return on Capital employed 12.9% 13.5% 13.5% 12.8% Operating Profit Margin 14.7% 18.2% 23.0% 14.4% Gross Profit Margin 54.7% 52.0% 49.3% 44.8% Efficiency Ratios Average Inventory Turnover period 79.8 83.3 93.0 78.8 Average settlement period for Accounts Receivable 28.0...
Please include comments on what you are doing.   Using linked lists, write a Python program that...
Please include comments on what you are doing.   Using linked lists, write a Python program that performs the following tasks: store the records for each college found in the input file - colleges.csv - into a linked list. (File includes name and state data fields) allow the user to search the linked list for a college’s name; display a message indicating whether or not the college’s name was in the database allow the user to enter a state's name and...
Write a Fraction Class in C++ PLEASE READ THE ASSINGMENT CAREFULY BEFORE YOU START, AND PLEASE,...
Write a Fraction Class in C++ PLEASE READ THE ASSINGMENT CAREFULY BEFORE YOU START, AND PLEASE, DON'T ANSWER IT IF YOU'RE NOT SURE WHAT YOU'RE DOING. I APPRECIATE IF YOU WRITE COMMENTS AS WELL. WRONG ANSWER WILL GET A DOWNVOTE Thank in Advance. Must do; The class must have 3 types of constructors; default, overloaded with initializer list, copy constructor You must overload the assignment operator You must declare the overloaded output operator as a friend rather than part of...
Using Python In this assignment we will try to add tuples, lists, if statements and strings...
Using Python In this assignment we will try to add tuples, lists, if statements and strings to our program. For example, you can ask for a user for a couple items, their name and age – and depending on their age, print out a predefined list. You could ask for some string input and decide to do something with the output. You could ask for three items, 1) age, 2) are you a male or female and 3) are your...
SETUP Before you begin, we'll need to start the Icecast server to emulate the CEO's computer....
SETUP Before you begin, we'll need to start the Icecast server to emulate the CEO's computer. Log onto the DVW10 machine (credentials IEUser:Passw0rd! ) and wait for the Icecast application to popup. Then click Start Server. Reminders A penetration tester's job is not just to gain access and find a file. Pentesters need to find all vulnerabilities, and document and report them to the client. It's quite possible that the CEO's workstation has multiple vulnerabilities. If a specific exploit doesn't...
You are going to start a company selling bottles of bacon soda (not baking soda). You...
You are going to start a company selling bottles of bacon soda (not baking soda). You have determined that to bottle your masterpiece, you’ll need to pay a bottling company $1.45 per bottle produced. They can send you 10 cases (48 bottles per case) for a $240 shipping cost. You’ll also need to hire someone to place your labels on each bottle once they arrive from the bottling company. You pay $.25 per label from an online supplier. Let’s assume...
PLEASE READ ALL OF THESE INSTRUCTIONS BEFORE BEGINNING THIS ASSIGNMENT. For this assignment, you need to...
PLEASE READ ALL OF THESE INSTRUCTIONS BEFORE BEGINNING THIS ASSIGNMENT. For this assignment, you need to analyze the information below from BOTH the management AND the employee perspective. This information pertains to a labor union in a simulated/made up/not real firm in Glen Ellyn. The first part of your information relates to Management – the second part relates to the Labor Union employees. I have provided you with information from the last union negotiations at the plant in 2016. It...
Overview: You will write a python program that will work with lists and their methods allowing...
Overview: You will write a python program that will work with lists and their methods allowing you to manipulate the data in the list. Additionally you will get to work with randomization. Instructions: Please carefully read the Instructions and Grading Criteria. Write a python program that will use looping constructs as noted in the assignment requirements. Name your program yourlastname_asgn5.py Assignment Requirements IMPORTANT: Follow the instructions below explicitly. Your program must be structured as I describe below. Write a Python...
So pretty much I need my code without the arrays, or lists. Please and thank you!...
So pretty much I need my code without the arrays, or lists. Please and thank you! Important: You may not use arrays, lists, or similar for your questions. This will be covered in the next module. The objective is to use conditionals in order to achieve the overall task. Checkpoint 3 is a continuation of the “Quiz” Programming Project. This module week, you will implement repetitive tasks in your program while using conditional and iteration statements in C#. Implement a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT