我有个编码问题要解决。我做了一半,但我想不出休息的时间。
以下是问题所在:
你有一群朋友来参加你的高中聚会,你想带他们去当地的一家餐馆吃饭。你不知道他们是否有饮食限制,但你的餐厅选择如下:乔的美食汉堡-素食主义者:不,维甘:不,无麸质:不
主街比萨公司-素食:是的,织女星:不,无麸质:是的
街角咖啡厅-素食主义者:是的,维根:是的,无麸质:是的
妈妈的意大利菜-素食主义者:是的,维甘:不,无麸质:不
素食主义者:是的,素食主义者:是的,无麸质:是的,写一个程序,询问你的聚会中是否有素食、素食或无麸质,然后只展示你可以带他们去的餐馆。
下面是程序输出的一个示例:
Is anyone in your party a vegetarian ? yes
Is anyone in your party a vegan ? no
Is anyone in your party gluten-free ? yes
Here are your restaurant choices:
Main Street Pizza Company
Corner Cafe
The Chef's Kitchen下面是程序输出的另一个示例:
Is anyone in your party a vegetarian ? yes
Is anyone in your party a vegan ? yes
Is anyone in your party gluten-free ? yes
Here are your restaurants choices:
Corner Cafe
The Chef's Kitchen下面是我到目前为止编写的代码:
# Get the status of a party
vegetarian = input('Is anyone in your party a vegetarian(yes/no)? ')
vegan = input('Is anyone in your party a vegan(yes/no)? ')
gluten_free = input('Is anyone in your party gluten-free(yes/or)? ')
# Assign restaurants based on the status of a party
if vegetarian == 'yes' and vegan == 'yes' and gluten_free == 'yes':
print("Here are your restaurant choices: \n"
"Corner Cafe \n"
"The Chef's Kitchen")
elif vegetarian == 'no' and vegan == 'no' and gluten_free == 'no':
print("Here are your restaurant choices: \n"
"Joe's Gourmet Burgers")这是输出:
Is anyone in your party a vegetarian(yes/no)? yes
Is anyone in your party a vegan(yes/no)? yes
Is anyone in your party gluten-free(yes/or)? yes
Here are your restaurant choices:
Corner Cafe
The Chef's KitchenIs anyone in your party a vegetarian(yes/no)? no
Is anyone in your party a vegan(yes/no)? no
Is anyone in your party gluten-free(yes/or)? no
Here are your restaurant choices:
Joe's Gourmet Burgers我想要的是写一份声明,根据答案随机选择餐馆。
但我能想出办法。
有人能告诉我怎么做吗?
我没有谷歌。我想学习。不是抄袭。提前谢谢你。
https://stackoverflow.com/questions/70302674
复制相似问题