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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!