Amelia-James commited on
Commit
f62874c
ยท
verified ยท
1 Parent(s): 6ce8d39

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -0
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import random
3
+
4
+ # Page config (wide layout + nicer title)
5
+ st.set_page_config(page_title="๐ŸŽฎ Rock Paper Scissors", layout="wide")
6
+
7
+ # Custom CSS for buttons
8
+ st.markdown("""
9
+ <style>
10
+ .btn-img {
11
+ background:none;
12
+ border:none;
13
+ padding: 10px;
14
+ cursor: pointer;
15
+ }
16
+ .btn-img:hover {
17
+ transform: scale(1.2);
18
+ transition-duration: 0.2s;
19
+ }
20
+ </style>
21
+ """, unsafe_allow_html=True)
22
+
23
+ st.title("๐Ÿชจ๐Ÿ“„โœ‚๏ธ Rock Paper Scissors")
24
+
25
+ # Show choices as images (you can replace URLs with your own hosted images)
26
+ col1, col2, col3 = st.columns(3)
27
+
28
+ with col1:
29
+ if st.button("๐Ÿชจ Rock", key="rock"):
30
+ user_choice = "Rock"
31
+ with col2:
32
+ if st.button("๐Ÿ“„ Paper", key="paper"):
33
+ user_choice = "Paper"
34
+ with col3:
35
+ if st.button("โœ‚๏ธ Scissors", key="scissors"):
36
+ user_choice = "Scissors"
37
+
38
+ try:
39
+ user_choice
40
+ except NameError:
41
+ st.write("๐Ÿ‘‰ **Choose Rock, Paper, or Scissors to start!**")
42
+ else:
43
+ # Computer move
44
+ computer_choice = random.choice(["Rock", "Paper", "Scissors"])
45
+
46
+ # Display choices
47
+ st.markdown(f"๐Ÿ’ก **You chose:** {user_choice}")
48
+ st.markdown(f"๐Ÿค– **Computer chose:** {computer_choice}")
49
+
50
+ # Result logic
51
+ if user_choice == computer_choice:
52
+ st.info("๐Ÿค It's a tie!")
53
+ elif (
54
+ (user_choice == "Rock" and computer_choice == "Scissors") or
55
+ (user_choice == "Paper" and computer_choice == "Rock") or
56
+ (user_choice == "Scissors" and computer_choice == "Paper")
57
+ ):
58
+ st.balloons()
59
+ st.success("๐ŸŽ‰ You win!")
60
+ else:
61
+ st.error("๐Ÿ˜ข You lose!")