import streamlit as st def generate_recommendations(party_on_weekends, flavor_preference, texture_dislike, price_range): # Define the list of ingredients ingredients = ["oranges", "apples", "pears", "grapes", "watermelon", "lemon", "lime"] # Apply the rules based on user answers allowed_fruits = ingredients.copy() if party_on_weekends == "yes": allowed_fruits = list(set(allowed_fruits) & set(["apples", "pears", "grapes", "watermelon"])) if flavor_preference == "cider": allowed_fruits = list(set(allowed_fruits) & set(["apples", "oranges", "lemon", "lime"])) elif flavor_preference == "sweet": allowed_fruits = list(set(allowed_fruits) & set(["watermelon", "oranges"])) elif flavor_preference == "waterlike": allowed_fruits = list(set(allowed_fruits) & set(["watermelon"])) if "grapes" in allowed_fruits: allowed_fruits.remove("watermelon") if texture_dislike == "smooth": if "pears" in allowed_fruits: allowed_fruits.remove("pears") elif texture_dislike == "slimy": slimy_fruits = ["watermelon", "lime", "grapes"] allowed_fruits = list(set(allowed_fruits) - set(slimy_fruits)) elif texture_dislike == "waterlike": if "watermelon" in allowed_fruits: allowed_fruits.remove("watermelon") if price_range < 3: if "lime" in allowed_fruits: allowed_fruits.remove("lime") if "watermelon" in allowed_fruits: allowed_fruits.remove("watermelon") elif 4 < price_range < 7: if "pears" in allowed_fruits: allowed_fruits.remove("pears") if "apples" in allowed_fruits: allowed_fruits.remove("apples") return allowed_fruits # Streamlit UI st.title("Fruit Recommendations App") # Take user input for each question party_answer = st.radio("Do you go out to party on weekends?", options=["Yes", "No"]) flavor_answer = st.radio("What flavors do you like?", options=["Cider", "Sweet", "Waterlike"]) texture_answer = st.radio("What texture do you dislike?", options=["Smooth", "Slimy", "Waterlike"]) price_answer = st.slider("What price range will you buy a drink for? ($1-$10)", min_value=1, max_value=10, value=5) # Call the function with user inputs party_on_weekends = "yes" if party_answer.lower() == "yes" else "no" recommendations = generate_recommendations(party_on_weekends, flavor_answer.lower(), texture_answer.lower(), price_answer) # Display recommendations st.subheader("Recommended Fruits:") st.write(recommendations)