Spaces:
Sleeping
Sleeping
| # Importing required libraries | |
| import random | |
| import streamlit as st | |
| # Title of the app | |
| st.title("Scissors, Paper, Rock Game") | |
| # Instructions for the game | |
| st.write("Welcome to the Scissors, Paper, Rock Game!") | |
| st.write("Choose one option and play against the computer!") | |
| # List of choices | |
| choices = ["Scissors", "Paper", "Rock"] | |
| # User choice | |
| user_choice = st.radio("Your Choice:", choices) | |
| # Computer choice | |
| if st.button("Play"): | |
| computer_choice = random.choice(choices) | |
| st.write(f"Computer chose: {computer_choice}") | |
| # Determine the winner | |
| if user_choice == computer_choice: | |
| st.success("It's a draw!") | |
| elif ( | |
| (user_choice == "Scissors" and computer_choice == "Paper") | |
| or (user_choice == "Paper" and computer_choice == "Rock") | |
| or (user_choice == "Rock" and computer_choice == "Scissors") | |
| ): | |
| st.success("You win!") | |
| else: | |
| st.error("You lose!") | |
| # Footer | |
| st.write("Enjoy the game and play again!") |