Joey889 commited on
Commit
fd35dd1
·
verified ·
1 Parent(s): 588ddaf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+
4
+ mole_pos = random.randint(1, 9)
5
+
6
+ def whack(choice):
7
+ global mole_pos
8
+ result = "打中了!" if int(choice) == mole_pos else "沒打中!"
9
+ mole_pos = random.randint(1, 9)
10
+ return result
11
+
12
+ iface = gr.Interface(fn=whack,
13
+ inputs=gr.Radio(choices=[str(i) for i in range(1, 10)], label="選擇洞口"),
14
+ outputs="text",
15
+ title="打地鼠遊戲",
16
+ description="點選你想打的洞口!")
17
+ iface.launch()