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.
- Use a for loop to iterate over the restaurants dictionary.
- 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started