TORONTO KIDS COMPUTER CLUB | Tuesday 7:30 Python Practice – 22.04.05.
20524
post-template-default,single,single-post,postid-20524,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Tuesday 7:30 Python Practice – 22.04.05.

08 Apr Tuesday 7:30 Python Practice – 22.04.05.

Question:
Create a class called Food. The class should contain three class attributes, the name of the food(string), the sugar(int or float), and the fat(int or float) content.

The tastiness of a particular food is based on the amount of sugar + fat that food has. So we
will need a class function to calculate the tastiness.

Now onto the static members in our class, we should have a static variable called all_foods. This
will be a list and whenever a new food is instantiated (created), that new food will get added to this list.

Finally, create a static function called get_tastiest that returns the tastiest food from all_foods.

Make sure that all_foods is storing the entire Food object and not just the name as a string!

No Comments

Sorry, the comment form is closed at this time.