-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeal_pick.py
46 lines (40 loc) · 1.47 KB
/
meal_pick.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
""" First personal python project """
import pandas as pd
import time
csv_dir = r"path\to\csv"
mealdir = r"{csv_dir}\meals_df.csv"
def meal_choice(time, mealdir, health_l, difficulty_l):
"""
randomly choose an item from df depending on user input
time = breakfast, lunch or dinner
health_l = healthy, kinda, nah
difficulty_l = easy, medium, difficult
"""
df_meals = pd.read_csv(mealdir, sep="\t")
filtered = df_meals.query(
"meal_time == @time and health == @health_l and difficulty == @difficulty_l"
)["meal"]
filtered = filtered.sample()
return filtered.to_string(index=False)
while True:
meal_time = input("Hello! Enter meal type (breakfast, lunch or dinner): ").lower()
health = input("How healthy? (healthy, kinda or nah): ").lower()
level = input("Enter difficulty level (easy, medium or hard): ").lower()
if (
meal_time in df_meals.values
and health in df_meals.values
and level in df_meals.values
):
print(f"your meal is: {meal_choice(meal_time, health, level)}")
time.sleep(0.8)
yesno = input("are you happy with this meal? (y/n) ")
if yesno == "y":
time.sleep(0.5)
print("Enjoy your meal!!")
break
else:
time.sleep(0.8)
print("Please try again")
else:
time.sleep(0.8)
print("Please enter one of the options in the brackets")