Sasimon8987 commited on
Commit
2c54e32
1 Parent(s): 299d75e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,10 +1,22 @@
1
  import gradio as gr
2
  import random as rd
3
-
 
 
 
 
 
 
 
 
 
4
  with gr.Blocks() as myApp:
5
  with gr.Row():
6
  with gr.Column(scale=1):
7
- inp=gr.Radio(choices=list(range(10)),label='เลือกตัวเลข')
 
8
  with gr.Column(scale=1):
9
- out=gr.Textbox(label='ผลลัพธ์')
 
 
10
  myApp.launch()
 
1
  import gradio as gr
2
  import random as rd
3
+ rand = rd.randint(0,9)
4
+ def guess(num):
5
+ num = int(num)
6
+ if num == rand:
7
+ r = 'ทายถูกแล้ว'
8
+ else:
9
+ r = 'ลองกดใหม่นะ'
10
+ return I
11
+ def answer():
12
+ return 'เลขสุ่มที่ได้ คือ' +str(rand)
13
  with gr.Blocks() as myApp:
14
  with gr.Row():
15
  with gr.Column(scale=1):
16
+ inp =gr.Radio(choices=list(range(10)),label='เลือกตัวเลข')
17
+ btn =gr.Button(value='เฉลย')
18
  with gr.Column(scale=1):
19
+ out=gr.Textbox(label='ผลลัพธ์')
20
+ inp.change(guess,inp,out)
21
+ btn.click(fn=answer,outputs=out)
22
  myApp.launch()