TORONTO KIDS COMPUTER CLUB | Tuesday 17:00 Python Practice – 22.05.10.
post-template-default,single,single-post,postid-20638,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Tuesday 17:00 Python Practice – 22.05.10.

13 May Tuesday 17:00 Python Practice – 22.05.10.

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.