Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import random | |
| # Page config (wide layout + nicer title) | |
| st.set_page_config(page_title="๐ฎ Rock Paper Scissors", layout="wide") | |
| # Custom CSS for buttons | |
| st.markdown(""" | |
| <style> | |
| .btn-img { | |
| background:none; | |
| border:none; | |
| padding: 10px; | |
| cursor: pointer; | |
| } | |
| .btn-img:hover { | |
| transform: scale(1.2); | |
| transition-duration: 0.2s; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| st.title("๐ชจ๐โ๏ธ Rock Paper Scissors") | |
| # Show choices as images (you can replace URLs with your own hosted images) | |
| col1, col2, col3 = st.columns(3) | |
| with col1: | |
| if st.button("๐ชจ Rock", key="rock"): | |
| user_choice = "Rock" | |
| with col2: | |
| if st.button("๐ Paper", key="paper"): | |
| user_choice = "Paper" | |
| with col3: | |
| if st.button("โ๏ธ Scissors", key="scissors"): | |
| user_choice = "Scissors" | |
| try: | |
| user_choice | |
| except NameError: | |
| st.write("๐ **Choose Rock, Paper, or Scissors to start!**") | |
| else: | |
| # Computer move | |
| computer_choice = random.choice(["Rock", "Paper", "Scissors"]) | |
| # Display choices | |
| st.markdown(f"๐ก **You chose:** {user_choice}") | |
| st.markdown(f"๐ค **Computer chose:** {computer_choice}") | |
| # Result logic | |
| if user_choice == computer_choice: | |
| st.info("๐ค 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") | |
| ): | |
| st.balloons() | |
| st.success("๐ You win!") | |
| else: | |
| st.error("๐ข You lose!") |