arxivgpt kim commited on
Commit
b1efa62
1 Parent(s): 8dd2edf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -28,11 +28,9 @@ scores = [
28
  [6, 7, 8]
29
  ]
30
 
31
- def calculate_score(answers):
32
- total_score = 0
33
- for i, ans in enumerate(answers):
34
- total_score += scores[i][options[i].index(ans)]
35
- return total_score
36
 
37
  with gr.Blocks() as demo:
38
  with gr.Tab("퀴즈 1"):
@@ -45,13 +43,12 @@ with gr.Blocks() as demo:
45
  answer5 = gr.Radio(choices=options[4], label=questions[4])
46
  answer6 = gr.Radio(choices=options[5], label=questions[5])
47
  submit_btn = gr.Button("제출")
 
48
 
49
- result = gr.Textbox(label="총점")
50
-
51
- submit_btn.click(
52
- fn=calculate_score,
53
- inputs=[answer1, answer2, answer3, answer4, answer5, answer6],
54
- outputs=result
55
- )
56
 
57
  demo.launch()
 
28
  [6, 7, 8]
29
  ]
30
 
31
+ def calculate_score(*answers):
32
+ total_score = sum([scores[i][options[i].index(answer)] for i, answer in enumerate(answers)])
33
+ return f"총점: {total_score}"
 
 
34
 
35
  with gr.Blocks() as demo:
36
  with gr.Tab("퀴즈 1"):
 
43
  answer5 = gr.Radio(choices=options[4], label=questions[4])
44
  answer6 = gr.Radio(choices=options[5], label=questions[5])
45
  submit_btn = gr.Button("제출")
46
+ result = gr.Textbox(label="결과")
47
 
48
+ submit_btn.click(
49
+ fn=calculate_score,
50
+ inputs=[answer1, answer2, answer3, answer4, answer5, answer6],
51
+ outputs=result
52
+ )
 
 
53
 
54
  demo.launch()