File size: 951 Bytes
0c0d366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)