File size: 1,087 Bytes
bbcedba
 
 
 
 
 
81d59c5
bbcedba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# Function to determine the winner
def get_winner(user_choice, computer_choice):
    if user_choice == computer_choice:
        return "It's a Tie!"
    elif (user_choice == "Rock" and computer_choice == "Scissors") or \
         (user_choice == "Paper" and computer_choice == "Rock") or \
         (user_choice == "Scissors" and computer_choice == "Paper"):
        return "You Win! πŸŽ‰"
    else:
        return "You Lose! πŸ˜”"

# Streamlit App
st.title("Rock-Paper-Scissors Game βœ‚οΈπŸ“„βœŠ")
st.subheader("Play a quick game and test your luck!")

# User's choice
user_choice = st.radio("Choose your move:", ["Rock", "Paper", "Scissors"], index=0)

# Generate computer's choice
computer_choice = random.choice(["Rock", "Paper", "Scissors"])

# Play button
if st.button("Play!"):
    result = get_winner(user_choice, computer_choice)

    # Display results
    st.write(f"**Your choice:** {user_choice}")
    st.write(f"**Computer's choice:** {computer_choice}")
    st.subheader(result)

st.write("Have fun! Refresh the page to play again.")