Python健康饮食推荐系统程序设计代码
时间: 2023-09-06 11:10:31 浏览: 205
以下是一个简单的Python健康饮食推荐系统的程序设计代码:
```python
import random
# 定义不同类型的食物列表
vegetables = ["lettuce", "spinach", "kale", "broccoli", "carrots", "tomatoes"]
fruits = ["apples", "bananas", "oranges", "grapes", "strawberries"]
grains = ["oats", "brown rice", "quinoa", "whole wheat bread", "barley"]
proteins = ["chicken", "fish", "tofu", "lentils", "beans"]
# 获取用户输入的信息
print("Welcome to the Healthy Eating Recommender!")
print("What type of food are you in the mood for?")
print("1. Vegetables")
print("2. Fruits")
print("3. Grains")
print("4. Proteins")
choice = input("Enter your choice (1-4): ")
# 根据用户的选择随机推荐相应类型的食物
if choice == "1":
recommendation = random.choice(vegetables)
elif choice == "2":
recommendation = random.choice(fruits)
elif choice == "3":
recommendation = random.choice(grains)
elif choice == "4":
recommendation = random.choice(proteins)
else:
recommendation = "Sorry, we don't have any recommendations for that choice."
# 输出推荐的食物
print("We recommend: " + recommendation)
```
该程序会根据用户输入的数字来推荐相应类型的食物,然后随机从该类型的食物列表中选择一个食物来推荐。
阅读全文