Abdullah-Basar's picture
Create app.py
0c0d366 verified
raw
history blame
951 Bytes
import streamlit as st
import random
# Title
st.title("Rock-Paper-Scissors Game")
# Instructions
st.write("""
Welcome to the Rock-Paper-Scissors game!
Choose your option and see if you can beat the computer.
""")
# User input
choices = ["Rock", "Paper", "Scissors"]
user_choice = st.selectbox("Choose your move:", choices)
# Play the game
if st.button("Play"):
computer_choice = random.choice(choices)
# Determine the winner
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 results
st.write(f"**Your Choice:** {user_choice}")
st.write(f"**Computer's Choice:** {computer_choice}")
st.subheader(result)