bhagwandas commited on
Commit
58aa986
ยท
verified ยท
1 Parent(s): c75de2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +106 -0
app.py CHANGED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import streamlit as st
3
+ import random
4
+
5
+ # Page Configuration
6
+ st.set_page_config(
7
+ page_title="๐ŸŽฎ Rock Paper Scissors",
8
+ page_icon="โœŒ๏ธ",
9
+ layout="centered"
10
+ )
11
+
12
+ # Custom CSS for Funky Styling
13
+ st.markdown("""
14
+ <style>
15
+ .title {
16
+ text-align: center;
17
+ font-size: 3em;
18
+ font-weight: bold;
19
+ color: #FF6F61;
20
+ text-shadow: 2px 2px #FFE156;
21
+ }
22
+ .subtitle {
23
+ text-align: center;
24
+ font-size: 1.5em;
25
+ color: #4CAF50;
26
+ }
27
+ .choice {
28
+ font-size: 1.2em;
29
+ font-weight: bold;
30
+ color: #2196F3;
31
+ text-align: center;
32
+ }
33
+ .result {
34
+ text-align: center;
35
+ font-size: 1.5em;
36
+ font-weight: bold;
37
+ margin-top: 20px;
38
+ }
39
+ .win {
40
+ color: #4CAF50;
41
+ }
42
+ .lose {
43
+ color: #F44336;
44
+ }
45
+ .tie {
46
+ color: #FF9800;
47
+ }
48
+ .footer {
49
+ text-align: center;
50
+ margin-top: 50px;
51
+ font-size: 0.9em;
52
+ color: #777;
53
+ }
54
+ .play-button {
55
+ display: block;
56
+ margin: 20px auto;
57
+ padding: 10px 30px;
58
+ background: linear-gradient(135deg, #FF6F61, #FFE156);
59
+ border: none;
60
+ border-radius: 10px;
61
+ font-size: 1.2em;
62
+ font-weight: bold;
63
+ color: #fff;
64
+ cursor: pointer;
65
+ box-shadow: 2px 2px 5px #aaa;
66
+ }
67
+ </style>
68
+ """, unsafe_allow_html=True)
69
+
70
+ # Header
71
+ st.markdown("<h1 class='title'>๐ŸŽฎ Rock Paper Scissors</h1>", unsafe_allow_html=True)
72
+ st.markdown("<p class='subtitle'>Challenge the Computer and Win the Game!</p>", unsafe_allow_html=True)
73
+
74
+ # Choices
75
+ choices = ["๐Ÿชจ Rock", "๐Ÿ“„ Paper", "โœ‚๏ธ Scissors"]
76
+
77
+ # User Input
78
+ user_choice = st.selectbox("๐Ÿค” Make Your Move:", choices)
79
+ play_button = st.button("๐Ÿ”ฅ Play Now")
80
+
81
+ # Game Logic
82
+ if play_button:
83
+ computer_choice = random.choice(choices)
84
+
85
+ # Determine Winner
86
+ if user_choice == computer_choice:
87
+ result = "๐Ÿค It's a Tie!"
88
+ result_class = "tie"
89
+ elif (
90
+ (user_choice == "๐Ÿชจ Rock" and computer_choice == "โœ‚๏ธ Scissors") or
91
+ (user_choice == "๐Ÿ“„ Paper" and computer_choice == "๐Ÿชจ Rock") or
92
+ (user_choice == "โœ‚๏ธ Scissors" and computer_choice == "๐Ÿ“„ Paper")
93
+ ):
94
+ result = "๐ŸŽ‰ You Win!"
95
+ result_class = "win"
96
+ else:
97
+ result = "๐Ÿ˜ข You Lose!"
98
+ result_class = "lose"
99
+
100
+ # Display Results
101
+ st.markdown(f"<p class='choice'>๐Ÿ‘ค <b>Your Choice:</b> {user_choice}</p>", unsafe_allow_html=True)
102
+ st.markdown(f"<p class='choice'>๐Ÿค– <b>Computer's Choice:</b> {computer_choice}</p>", unsafe_allow_html=True)
103
+ st.markdown(f"<p class='result {result_class}'>{result}</p>", unsafe_allow_html=True)
104
+
105
+ # Footer
106
+ st.markdown("<p class='footer'>๐Ÿ’ป <b>Developed by ChatGPT</b></p>", unsafe_allow_html=True)