NaqchoAli's picture
Update app.py
e7b29c2 verified
import streamlit as st
import random
# Title of the app
st.title("Rock, Paper, Scissors Game")
# Game instructions
st.write("""
Choose Rock, Paper, or Scissors to play against the computer.
""")
# Player's choice
options = ['Rock', 'Paper', 'Scissors']
player_choice = st.selectbox("Choose your move:", options)
# Button to play the game
if st.button('Play'):
# Computer's random choice
computer_choice = random.choice(options)
# Display choices
st.write(f"Your choice: {player_choice}")
st.write(f"Computer's choice: {computer_choice}")
# Determine the result
if player_choice == computer_choice:
result = "It's a tie!"
elif (player_choice == 'Rock' and computer_choice == 'Scissors') or \
(player_choice == 'Paper' and computer_choice == 'Rock') or \
(player_choice == 'Scissors' and computer_choice == 'Paper'):
result = "You win!"
else:
result = "You lose!"
# Display the result
st.write(result)