Spaces:
Build error
Build error
| # app.py | |
| import streamlit as st | |
| import random | |
| # Page Configuration | |
| st.set_page_config( | |
| page_title="๐ฎ Rock Paper Scissors", | |
| page_icon="โ๏ธ", | |
| layout="centered" | |
| ) | |
| # Custom CSS for Funky Styling | |
| st.markdown(""" | |
| <style> | |
| .title { | |
| text-align: center; | |
| font-size: 3em; | |
| font-weight: bold; | |
| color: #FF6F61; | |
| text-shadow: 2px 2px #FFE156; | |
| } | |
| .subtitle { | |
| text-align: center; | |
| font-size: 1.5em; | |
| color: #4CAF50; | |
| } | |
| .choice { | |
| font-size: 1.2em; | |
| font-weight: bold; | |
| color: #2196F3; | |
| text-align: center; | |
| } | |
| .result { | |
| text-align: center; | |
| font-size: 1.5em; | |
| font-weight: bold; | |
| margin-top: 20px; | |
| } | |
| .win { | |
| color: #4CAF50; | |
| } | |
| .lose { | |
| color: #F44336; | |
| } | |
| .tie { | |
| color: #FF9800; | |
| } | |
| .footer { | |
| text-align: center; | |
| margin-top: 50px; | |
| font-size: 0.9em; | |
| color: #777; | |
| } | |
| .play-button { | |
| display: block; | |
| margin: 20px auto; | |
| padding: 10px 30px; | |
| background: linear-gradient(135deg, #FF6F61, #FFE156); | |
| border: none; | |
| border-radius: 10px; | |
| font-size: 1.2em; | |
| font-weight: bold; | |
| color: #fff; | |
| cursor: pointer; | |
| box-shadow: 2px 2px 5px #aaa; | |
| } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| # Header | |
| st.markdown("<h1 class='title'>๐ฎ Rock Paper Scissors</h1>", unsafe_allow_html=True) | |
| st.markdown("<p class='subtitle'>Challenge the Computer and Win the Game!</p>", unsafe_allow_html=True) | |
| # Choices | |
| choices = ["๐ชจ Rock", "๐ Paper", "โ๏ธ Scissors"] | |
| # User Input | |
| user_choice = st.selectbox("๐ค Make Your Move:", choices) | |
| play_button = st.button("๐ฅ Play Now") | |
| # Game Logic | |
| if play_button: | |
| computer_choice = random.choice(choices) | |
| # Determine Winner | |
| if user_choice == computer_choice: | |
| result = "๐ค It's a Tie!" | |
| result_class = "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") | |
| ): | |
| result = "๐ You Win!" | |
| result_class = "win" | |
| else: | |
| result = "๐ข You Lose!" | |
| result_class = "lose" | |
| # Display Results | |
| st.markdown(f"<p class='choice'>๐ค <b>Your Choice:</b> {user_choice}</p>", unsafe_allow_html=True) | |
| st.markdown(f"<p class='choice'>๐ค <b>Computer's Choice:</b> {computer_choice}</p>", unsafe_allow_html=True) | |
| st.markdown(f"<p class='result {result_class}'>{result}</p>", unsafe_allow_html=True) | |
| # Footer | |
| st.markdown("<p class='footer'>๐ป <b>Developed by ChatGPT</b></p>", unsafe_allow_html=True) | |