Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!