Spaces:
Sleeping
Sleeping
| 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) | |