Question
Write a Python class named Food constructed by name of food, quantity of servings of food, calory of one serving, a method which will set
Write a Python class named Food constructed by name of food, quantity of servings of food, calory of one serving, a method which will set the food with specified name, quantity of servings and calory of one serving, a second method which returns the quantity of servings of food, and a third method which returns the total calory with consumption of the food. (30 pts)
Next, create one hundred different foods with different names (please do not list all of the one hundreds, just give the code for the first two foods). Then use List comprehension to find the top three foods which have the most total calories and display their names, quantity of servings of food and total calory consumed. (10 pts)
Lastly, use itertoolss groupby() method to group the one hundred food by their calories of one serving into dictionaries, which will use calory of one serving as key, and list of foods as value (10 pts)
Please complete this question in Jupyter Notebook and run it to generate the result. Then upload your notebook using the "Insert" tab on the menu bar to upload your notebook with its running result. You can also copy and paste your code and its running result in the provided text area.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started