Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

Students also viewed these Databases questions