UsmanGoraya's picture
Create app.py
68b5f4b verified
raw
history blame contribute delete
994 Bytes
import streamlit as st
import random
st.set_page_config(page_title="Rock Paper Scissors", page_icon="✌️")
st.title("πŸͺ¨πŸ“„βœ‚οΈ Rock, Paper, Scissors Game")
choices = ['Rock', 'Paper', 'Scissors']
emojis = {'Rock': 'πŸͺ¨', 'Paper': 'πŸ“„', 'Scissors': 'βœ‚οΈ'}
# Player choice
player_choice = st.selectbox("Choose your move:", choices)
# Play button
if st.button("Play"):
computer_choice = random.choice(choices)
st.write(f"**You chose:** {player_choice} {emojis[player_choice]}")
st.write(f"**Computer chose:** {computer_choice} {emojis[computer_choice]}")
# Game logic
if player_choice == computer_choice:
result = "It's a draw!"
elif (player_choice == 'Rock' and computer_choice == 'Scissors') or \
(player_choice == 'Scissors' and computer_choice == 'Paper') or \
(player_choice == 'Paper' and computer_choice == 'Rock'):
result = "πŸŽ‰ You win!"
else:
result = "😒 You lose!"
st.subheader(result)