Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please help me with the python code for this below: Thank you! 1. A Food is a dictionary with three string keys: name

Can someone please help me with the python code for this below: Thank you!

1. A Food is a dictionary with three string keys:

"name" will be associated with a string value representing the name of the food

"calories" will be associated with an integer value representing the number of calories in the food

"vegan" will be associated with a boolean value indicating whether the food is vegan-friendly

For example, here are two foods:

legume = {"name": "Legume", "calories": 200, "vegan": True} pizza = {"name": "Pepperoni Pizza", "calories": 800, "vegan": False}

Define a function sum_vegan_calories that consumes a list of Food dictionaries and produces an integer representing the total calories of all the Vegan food. If you encounter a food named "exit" then stop processing the list and return the sum up until that point. You get partial credit for completing as many cases as you can.

You are not required to document of unit test the function.

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_2

Step: 3

blur-text-image_3

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

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions