Download app.py from SanaAdeel/Magic: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/spaces/SanaAdeel/Magic/resolve/main/app.py
- Command line
-
hf download hf://spaces/SanaAdeel/Magic/app.py
-
curl -L -o app.py https://huggingface.co/spaces/SanaAdeel/Magic/resolve/main/app.py
1.74 kB
| import streamlit as st | |
| # Function to start the guessing process | |
| def start_game(): | |
| st.title("Mind-Reading Number Game") | |
| # Instructions for the user | |
| st.write("Welcome to the Mind-Reading Number Game!") | |
| st.write("Please think of a number between 1 and 100, but do not tell me what it is.") | |
| st.write("Then, follow the instructions carefully.") | |
| # Step 1: Ask the user to perform a series of operations | |
| st.write("Step 1: Multiply your number by 2.") | |
| number_1 = st.number_input("Enter your result after multiplying by 2", min_value=2, step=1, key="number_1") | |
| # Step 2: Add 8 to the result | |
| st.write("Step 2: Now, add 8 to the result.") | |
| number_2 = st.number_input("Enter your result after adding 8", min_value=10, step=1, key="number_2") | |
| # Step 3: Divide the result by 2 | |
| st.write("Step 3: Divide the result by 2.") | |
| number_3 = st.number_input("Enter your result after dividing by 2", min_value=5, step=1, key="number_3") | |
| # Step 4: Subtract the original number you thought of | |
| st.write("Step 4: Now, subtract the original number you thought of.") | |
| number_4 = st.number_input("Enter your result after subtracting your original number", min_value=0, step=1, key="number_4") | |
| # Final calculation to guess the number | |
| if number_1 and number_2 and number_3 and number_4: | |
| # The number the user thought of can be found as follows: | |
| guessed_number = number_4 - 4 # The final result is the user's number minus 4 | |
| st.write(f"Your original number is: **{guessed_number}**!") | |
| # Button to restart the game | |
| if st.button("Restart Game"): | |
| start_game() | |
| st.experimental_rerun() | |
| # Start the game | |
| start_game() | |