Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -64,4 +64,40 @@ def prev_q():
|
|
| 64 |
global question_index
|
| 65 |
if history:
|
| 66 |
question_index = history.pop()
|
| 67 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
global question_index
|
| 65 |
if history:
|
| 66 |
question_index = history.pop()
|
| 67 |
+
return show_question()
|
| 68 |
+
|
| 69 |
+
# ๐จ Gradio UI
|
| 70 |
+
with gr.Blocks(theme=gr.themes.Base(primary_hue="green", secondary_hue="pink")) as app:
|
| 71 |
+
gr.Markdown("## ๐ Python Fun Quiz Game for Kids ๐ฎ")
|
| 72 |
+
with gr.Row():
|
| 73 |
+
score_box = gr.Textbox(label="๐ Your Score", interactive=False, value="โญ Score: 0")
|
| 74 |
+
hint_box = gr.Textbox(label="๐ก Hint", interactive=False)
|
| 75 |
+
code_display = gr.Textbox(label="๐ง What will this Python code print?", lines=2, interactive=False)
|
| 76 |
+
options = gr.Radio(choices=[], label="๐ง Choose your answer")
|
| 77 |
+
result = gr.Textbox(label="๐ฏ Result", interactive=False)
|
| 78 |
+
|
| 79 |
+
with gr.Row():
|
| 80 |
+
btn_check = gr.Button("โ
Check Answer")
|
| 81 |
+
btn_hint = gr.Button("๐ก Get Hint")
|
| 82 |
+
btn_skip = gr.Button("โญ๏ธ Skip")
|
| 83 |
+
btn_back = gr.Button("โช Back")
|
| 84 |
+
|
| 85 |
+
btn_check.click(fn=check_answer, inputs=options, outputs=[result, score_box])
|
| 86 |
+
btn_hint.click(fn=get_hint, outputs=hint_box)
|
| 87 |
+
btn_skip.click(fn=skip_question, outputs=[code_display, options, result, score_box])
|
| 88 |
+
btn_back.click(fn=prev_q, outputs=[code_display, options, result, score_box])
|
| 89 |
+
|
| 90 |
+
# Load first question
|
| 91 |
+
app.load(show_question, outputs=[code_display, options, result, score_box])
|
| 92 |
+
|
| 93 |
+
gr.Markdown("---")
|
| 94 |
+
gr.Markdown("## ๐ Coming Soon: Unique Games")
|
| 95 |
+
gr.Markdown("""
|
| 96 |
+
- ๐ค **Python Word Scramble**: Rearrange jumbled Python keywords
|
| 97 |
+
- ๐ฒ **Code Dice**: Roll a die to get random challenges
|
| 98 |
+
- ๐งฉ **Puzzle Blocks**: Drag code blocks to form a working program
|
| 99 |
+
- ๐งโโ๏ธ **Code Fairy Tales**: Read stories and guess what the code will do
|
| 100 |
+
""")
|
| 101 |
+
|
| 102 |
+
app.launch()
|
| 103 |
+
|