Spaces:
Sleeping
Sleeping
File size: 1,184 Bytes
9fc4347 |
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 |
import streamlit as st
import random
# Title of the app
st.title("Rock, Paper, Scissors Game")
# Rules and instructions
st.write("Welcome to Rock, Paper, Scissors!")
st.write("Choose your option below and see if you can beat the computer.")
st.write("Rules:")
st.write("- Rock beats Scissors")
st.write("- Scissors beats Paper")
st.write("- Paper beats Rock")
# Options
options = ["Rock", "Paper", "Scissors"]
# User input
user_choice = st.radio("Select your choice:", options)
# Button to play
if st.button("Play"):
# Computer's random choice
computer_choice = random.choice(options)
# Display choices
st.write(f"You chose: **{user_choice}**")
st.write(f"The computer chose: **{computer_choice}**")
# Determine the result
if user_choice == computer_choice:
result = "It's a tie!"
elif (user_choice == "Rock" and computer_choice == "Scissors") or \
(user_choice == "Scissors" and computer_choice == "Paper") or \
(user_choice == "Paper" and computer_choice == "Rock"):
result = "You win! 🎉"
else:
result = "You lose! 😢"
# Display result
st.write(f"**Result:** {result}")
|