Hi, Programming Exercises 157 THON 18. Restaurant Selector You have a group of f
ID: 3871943 • Letter: H
Question
Hi,
Programming Exercises 157 THON 18. Restaurant Selector You have a group of friends coming to visit for your high school reunion, and you want to take them out to eat at a local restaurant. You aren't sure if any of them have dietary restrictions, but your restaurant choices are as follows: Joe's Gourmet Burgers-Vegetarian: No, Vegan: No, Gluten-Free: No Main Street Pizza Company-Vegetarian: Yes, Vegan: No, Gluten-Free: Yes Corner Café-Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes Mama's Fine Italian-Vegetarian: Yes, Vegan: No, Gluten-Free: No The Chef's Kitchen-Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes Programing , Processing tion Structur etion Write a program that asks whether any members of your party are vegetarian, vegan, or gluten-free, to which then displays only the restaurants to which you may take the group ctons and ample of the program'so and Tuples eAbcut Slrings anaries and eses and Is anyone in your party a vegetarian? yes Enter Is anyone in your party a vegan? no Enter Is anyone in your party gluten-free? yes Enter Here are your restaurant choices Programming curslcn Main Street Pizza Company Corner Cafe The Chef's Kitchen e here to searchExplanation / Answer
Hi,
Please find below the code. I have added the comments. You wont find any difficulty or issue in running this code. Please let me know if you face any issue.Thanks.
#Dictionary of all restaurants available.
JGB = {'Vegetarian' : 'No', 'Vegan': 'No', 'Glutenfree': 'No'}
MSPC = {'Vegetarian' : 'Yes', 'Vegan': 'No', 'Glutenfree': 'Yes'}
CC = {'Vegetarian' : 'Yes', 'Vegan': 'Yes', 'Glutenfree': 'Yes'}
MFI = {'Vegetarian' : 'Yes', 'Vegan': 'No', 'Glutenfree': 'No'}
TCK = {'Vegetarian' : 'Yes', 'Vegan': 'Yes', 'Glutenfree': 'Yes'}
restaurant_list = [JGB,MSPC,CC,MFI,TCK]
#Asking th user to enter if party members are vegetarian/vegan/gluten-free?
Vegetarian = input("Is anyone in your party a vegetarian?")
Vegan = input("Is anyone in your party a vegan?")
Glutenfree = input("Is anyone in your party a gluten-free?")
#Extracting the variety of the party member's diet.
diet_list = []
if Vegetarian == 'yes':
diet_list.append('Vegetarian')
if Vegan == 'yes':
diet_list.append('Vegan')
if Glutenfree == 'yes':
diet_list.append('Glutenfree')
#According to the party member's diet, extracting the restaurant choices.
restaurant_choices = []
for var in restaurant_list:
flag = 1
for diet in diet_list:
if var[diet] == 'No':
flag = 0
break
if flag==1:
restaurant_choices.append(var)
#Extracting the names of the restaurants.
final = []
print("Here are your restaurant choices: ")
for res in restaurant_choices:
if res == JGB:
final.append("Joe's Gourmet Burgers")
if res == MSPC:
final.append("Main Street Pizza Company")
if res == CC:
final.append("Corner Cafe")
if res == MFI:
final.append("Mama's Fine Italian")
if res == TCK:
final.append("The Chef's Kitchen")
#Finally printing the names of the restaurants and removing the duplicates, if any.
myList = set(final)
for restaurantss in myList:
print(restaurantss)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.