Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This dictionary contains four restaurants and their menu items. Develop program that counts the total number of calories of the menu items for each restaurant

This dictionary contains four restaurants and their menu items. Develop program that counts the total number of calories of the menu items for each restaurant and outputs the result.

  1. Use a for loop to iterate over the restaurants dictionary.
  2. Inside the for loop, do the following:
    • A new variable calories to store the total calorie count of the restaurant.
    • A nested for loop to iterate over the menu items of the restaurant, taking each menu item's calorie count and adding it to the total calorie count contained in the calories variable.
    • Inside the outer loop, but outside the inner loop, print the restaurant name and the total number of calories of its menu items.

Correct Output of exercise.py: Burgertopia: 3050 calories Pizza Thyme: 2100 calories Taco Thursday: 1315 calories Fish Fish and More Fish: 1920 calories

Data:

restaurants = {

'Burgertopia':

{

'cheese burger': 540,

'chocolate shake': 210,

'french fries': 400,

'onion rings': 420,

'burger': 500,

'double burger': 980

},

'Pizza Thyme':

{

'cheese pizza': 350,

'pepperonni pizza': 600,

'vegetarian pizza': 450,

'meat pizza': 700

},

'Taco Thursday':

{

'al pastor tacos': 465,

'torta': 300,

'gorditas': 550

},

'Fish Fish and More Fish':

{

'salmon': 220,

'fried cod': 350,

'fish tacos': 650,

'fried calamari': 430,

'shrimp': 270

}

}

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

Business Law Today The Essentials

Authors: Roger LeRoy Miller, Gaylord A. Jentz

9th Edition

9780324786156, 324786344, 324786158, 9780324786347, 978-0324786156

More Books

Students also viewed these Programming questions