|
import streamlit as st |
|
import random |
|
|
|
|
|
st.title("Rock-Paper-Scissors Game") |
|
|
|
|
|
st.write(""" |
|
Welcome to the Rock-Paper-Scissors game! |
|
Choose your option and see if you can beat the computer. |
|
""") |
|
|
|
|
|
choices = ["Rock", "Paper", "Scissors"] |
|
user_choice = st.selectbox("Choose your move:", choices) |
|
|
|
|
|
if st.button("Play"): |
|
computer_choice = random.choice(choices) |
|
|
|
|
|
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! 😢" |
|
|
|
|
|
st.write(f"**Your Choice:** {user_choice}") |
|
st.write(f"**Computer's Choice:** {computer_choice}") |
|
st.subheader(result) |
|
|