Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import random | |
| # Define the dictionary lists for each organ | |
| HEART_LIST = [ | |
| {"name": "Heartbeat", "description": "The rhythmic contraction and expansion of the heart", "emoji": "β€οΈ"}, | |
| {"name": "Blood vessels", "description": "The network of tubes that carry blood throughout the body", "emoji": "π§"}, | |
| {"name": "Pulse", "description": "The rhythmic expansion and contraction of an artery as blood flows through it", "emoji": "π"} | |
| ] | |
| LUNG_LIST = [ | |
| {"name": "Breathing", "description": "The act of inhaling and exhaling air", "emoji": "π¬οΈ"}, | |
| {"name": "Respiration", "description": "The process by which oxygen is taken in and carbon dioxide is expelled", "emoji": "π¨"}, | |
| {"name": "Coughing", "description": "A reflex action that helps to clear the airways", "emoji": "π€§"} | |
| ] | |
| BRAIN_LIST = [ | |
| {"name": "Memory", "description": "The ability to store and retrieve information", "emoji": "π§ "}, | |
| {"name": "Concentration", "description": "The ability to focus on a task or idea", "emoji": "π"}, | |
| {"name": "Imagination", "description": "The ability to create mental images or ideas", "emoji": "π"} | |
| ] | |
| # Define a function to roll a 100 sided dice 10 times and return the rolls and the total score | |
| def roll_dice(): | |
| rolls = [random.randint(1, 100) for _ in range(10)] | |
| total_score = sum(rolls) | |
| return rolls, total_score | |
| # Define the Streamlit app | |
| def app(): | |
| st.sidebar.title("Choose an organ list") | |
| organ_list = st.sidebar.selectbox("Select an organ", ["Heart", "Lung", "Brain"]) | |
| st.write(f"## {organ_list} List") | |
| if organ_list == "Heart": | |
| selected_list = HEART_LIST | |
| elif organ_list == "Lung": | |
| selected_list = LUNG_LIST | |
| else: | |
| selected_list = BRAIN_LIST | |
| st.write("### Choose an item from the list") | |
| selected_item = st.selectbox("Select an item", [item["name"] for item in selected_list]) | |
| selected_item_dict = [item for item in selected_list if item["name"] == selected_item][0] | |
| st.write(f"### {selected_item_dict['name']} {selected_item_dict['emoji']}") | |
| st.write(selected_item_dict['description']) | |
| st.write("### Roll the dice") | |
| rolls, total_score = roll_dice() | |
| st.write("Rolls:", rolls) | |
| st.write("Total score:", total_score) | |
| st.write("### Aggregated score") | |
| scores = [roll_dice()[1] for _ in range(10)] | |
| st.write("Scores:", scores) | |
| st.write("Total score:", sum(scores)) | |
| if __name__ == '__main__': | |
| app() |