Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Yes, I have provided all 50 questions and answers. Here is the complete code:
|
| 2 |
+
Python
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import random
|
| 5 |
+
|
| 6 |
+
# Question bank with 50 questions, each with 4 options
|
| 7 |
+
question_bank = [
|
| 8 |
+
{"question": "What does the Gen Z term 'No cap' mean?", "options": ["No lie", "No truth", "No joke", "No fun"], "answer": "No lie"},
|
| 9 |
+
{"question": "What does the 80's term 'Rad' mean?", "options": ["Cool", "Uncool", "Happy", "Sad"], "answer": "Cool"},
|
| 10 |
+
{"question": "What does the Millennial term 'Adulting' mean?", "options": ["Acting like an adult", "Acting like a kid", "Being responsible", "Being irresponsible"], "answer": "Acting like an adult"},
|
| 11 |
+
{"question": "What does the Gen Z term 'Simp' mean?", "options": ["A simple person", "A smart person", "A kind person", "A foolish person"], "answer": "A foolish person"},
|
| 12 |
+
{"question": "What does the 90's term 'Talk to the hand' mean?", "options": ["I'm not listening", "I'm listening", "I'm busy", "I'm available"], "answer": "I'm not listening"},
|
| 13 |
+
{"question": "What does the Millennial term 'Slay' mean?", "options": ["To do poorly", "To do well", "To try hard", "To give up"], "answer": "To do well"},
|
| 14 |
+
{"question": "What does the Gen Z term 'Ghost' mean?", "options": ["To leave suddenly", "To stay forever", "To come back", "To never leave"], "answer": "To leave suddenly"},
|
| 15 |
+
{"question": "What does the 70's term 'Freak out' mean?", "options": ["To dance wildly", "To sing loudly", "To lose control", "To stay calm"], "answer": "To lose control"},
|
| 16 |
+
{"question": "What does the Millennial term 'Lowkey' mean?", "options": ["Secretly", "Openly", "Quietly", "Loudly"], "answer": "Secretly"},
|
| 17 |
+
{"question": "What does the Gen Z term 'Highkey' mean?", "options": ["Obviously", "Secretly", "Quietly", "Loudly"], "answer": "Obviously"},
|
| 18 |
+
{"question": "What does the 60's term 'Groovy' mean?", "options": ["Cool", "Uncool", "Happy", "Sad"], "answer": "Cool"},
|
| 19 |
+
{"question": "What does the Millennial term 'Shook' mean?", "options": ["Surprised", "Unimpressed", "Excited", "Bored"], "answer": "Surprised"},
|
| 20 |
+
{"question": "What does the Gen Z term 'Savage' mean?", "options": ["Cruel", "Kind", "Funny", "Sad"], "answer": "Cruel"},
|
| 21 |
+
{"question": "What does the 50's term 'Cool cat' mean?", "options": ["A cool person", "A mean person", "A happy person", "A sad person"], "answer": "A cool person"},
|
| 22 |
+
{"question": "What does the Gen Z term 'Lit' mean?", "options": ["Exciting", "Boring", "Happy", "Sad"], "answer": "Exciting"},
|
| 23 |
+
{"question": "What does the Millennial term 'Yaaas' mean?", "options": ["Yes", "No", "Maybe", "I don't know"], "answer": "Yes"},
|
| 24 |
+
{"question": "What does the Gen Z term 'No tea, no shade' mean?", "options": ["No gossip, no insult", "No news, no rumors", "No secrets, no lies", "No fun, no joke"], "answer": "No gossip, no insult"},
|
| 25 |
+
{"question": "What does the 90's term 'As if!' mean?", "options": ["I don't believe you", "I believe you", "I'm joking", "I'm serious"], "answer": "I don't believe you"},
|
| 26 |
+
{"question": "What does the Millennial term 'Salty' mean?", "options": ["Bitter", "Sweet", "Sour", "Umami"], "answer": "Bitter"},
|
| 27 |
+
{"question": "What does the Gen Z term 'Shooketh' mean?", "options": ["Surprised", "Unimpressed", "Excited", "Bored"], "answer": "Surprised"},
|
| 28 |
+
{"question": "What does the 80's term 'Gag me with a spoon' mean?", "options": ["I'm disgusted", "I'm happy", "I'm sad", "I'm angry"], "answer": "I'm disgusted"},
|
| 29 |
+
{"question": "What does the Gen Z term 'Simpsons' mean?", "options": ["A funny show", "A boring show", "A cartoon", "A reality show"], "answer": "A funny show"},
|
| 30 |
+
{"question": "What does the 50's term 'Cruisin' for a bruisin'' mean?", "options": ["Looking for trouble", "Looking for fun", "Looking for love", "Looking for friendship"], "answer": "Looking for trouble"},
|
| 31 |
+
{"question": "What does the 80's term 'Gnarly' mean?", "options": ["Cool", "Uncool", "Happy", "Sad"], "answer": "Cool"},
|
| 32 |
+
{"question": "What does the 70's term 'Freaky' mean?", "options": ["Weird", "Normal", "Happy", "Sad"], "answer": "Weird"},
|
| 33 |
+
{"question": "What does the Millennial term 'Turn up' mean?", "options": ["To have fun", "To be quiet", "To go home", "To stay in"], "answer": "To have fun"},
|
| 34 |
+
{"question": "What does the 60's term 'Vibes' mean?", "options": ["Good atmosphere", "Bad atmosphere", "Happy feelings", "Sad feelings"], "answer": "Good atmosphere"},
|
| 35 |
+
{"question": "What does the Millennial term 'Yikes' mean?", "options": ["I'm scared", "I'm happy", "I'm sad", "I'm angry"], "answer": "I'm scared"},
|
| 36 |
+
{"question": "What does the Gen Z term 'Bet' mean?", "options": ["Okay", "Not okay", "Maybe", "I don't know"], "answer": "Okay"},
|
| 37 |
+
{"question": "What does the 80's term 'Bogus' mean?", "options": ["Bad", "Good", "Happy", "Sad"], "answer": "Bad"},
|
| 38 |
+
{"question": "What does the Gen Z term 'Tea' mean?", "options": ["Gossip", "News", "Rumors", "Secrets"], "answer": "Gossip"},
|
| 39 |
+
{"question": "What does the 70's term 'Stay cool' mean?", "options": ["Stay calm", "Stay happy", "Stay sad", "Stay angry"], "answer": "Stay calm"},
|
| 40 |
+
{"question": "What does the Millennial term 'Turnt' mean?", "options": ["Exciting", "Boring", "Happy", "Sad"], "answer": "Exciting"},
|
| 41 |
+
{"question": "What does the 60's term 'Far out' mean?", "options": ["Cool", "Uncool", "Happy", "Sad"], "answer": "Cool"},
|
| 42 |
+
{"question": "What does the Millennial term 'Lowkey/Highkey' mean?", "options": ["Secretly/Openly", "Quietly/Loudly", "Happy/Sad", "Angry/Calm"], "answer": "Secretly/Openly"},
|
| 43 |
+
{"question": "What does the 50's term 'Square' mean?", "options": ["A cool person", "A mean person", "A happy person", "An uncool person"], "answer": "An uncool person"},
|
| 44 |
+
{"question": "What does the Millennial term 'Slayyed' mean?", "options": ["To do poorly", "To do well", "To try hard", "To give up"], "answer": "To do well"}
|
| 45 |
+
{"question": "What does the Gen Z term 'Cap' mean?", "options": ["To lie", "To tell the truth", "To joke", "To be serious"], "answer": "To lie"},
|
| 46 |
+
{"question": "What does the Millennial term 'Sis' mean?", "options": ["A friend", "A family member", "A stranger", "A enemy"], "answer": "A friend"},
|
| 47 |
+
{"question": "What does the 90's term 'Word' mean?", "options": ["True", "False", "Maybe", "I don't know"], "answer": "True"},
|
| 48 |
+
{"question": "What does the Gen Z term 'Mid' mean?", "options": ["Good", "Bad", "Okay", "Awful"], "answer": "Bad"},
|
| 49 |
+
{"question": "What does the 80's term 'Psyche' mean?", "options": ["To trick", "To help", "To joke", "To be serious"], "answer": "To trick"},
|
| 50 |
+
{"question": "What does the Millennial term 'Tea time' mean?", "options": ["Time for gossip", "Time for news", "Time for rumors", "Time for secrets"], "answer": "Time for gossip"},
|
| 51 |
+
{"question": "What does the 70's term 'Dig it' mean?", "options": ["To understand", "To not understand", "To like", "To dislike"], "answer": "To understand"},
|
| 52 |
+
{"question": "What does the Gen Z term 'No drama' mean?", "options": ["No conflict", "No fun", "No friends", "No life"], "answer": "No conflict"},
|
| 53 |
+
{"question": "What does the 60's term 'Hang loose' mean?", "options": ["To relax", "To worry", "To be happy", "To be sad"], "answer": "To relax"},
|
| 54 |
+
{"question": "What does the Millennial term 'Shade' mean?", "options": ["To insult", "To compliment", "To joke", "To be serious"], "answer": "To insult"},
|
| 55 |
+
{"question": "What does the 50's term 'Righteous' mean?", "options": ["Good", "Bad", "Happy", "Sad"], "answer": "Good"},
|
| 56 |
+
{"question": "What does the Gen Z term 'Salty' mean?", "options": ["Bitter", "Sweet", "Sour", "Umami"], "answer": "Bitter"},
|
| 57 |
+
{"question": "What does the 80's term 'Harshing the mellow' mean?", "options": ["To ruin the fun", "To enhance the fun", "To not affect the fun", "To leave the fun"], "answer": "To ruin the fun"},
|
| 58 |
+
{"question": "What does the Millennial term 'Yikes' mean?", "options": ["I'm scared", "I'm happy", "I'm sad", "I'm angry"], "answer": "I'm scared"},
|
| 59 |
+
{"question": "What does the 70's term 'Freak flag' mean?", "options": ["To express oneself", "To hide oneself", "To be different", "To be normal"], "answer": "To express oneself"}
|
| 60 |
+
]
|
| 61 |
+
]
|
| 62 |
+
|
| 63 |
+
# Help lines
|
| 64 |
+
help_lines = {
|
| 65 |
+
"50:50": lambda question: [option for option in question["options"] if option != question["answer"]][:2],
|
| 66 |
+
"Skip": None,
|
| 67 |
+
"Clue": lambda question: f"{question['answer']} is the correct answer."
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
# Game state
|
| 71 |
+
game_state = {
|
| 72 |
+
"current_question": 0,
|
| 73 |
+
"score": 0,
|
| 74 |
+
"safe_spots": [5, 10],
|
| 75 |
+
"help_lines_used": {"50:50": False, "Skip": False, "Clue": False}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
def get_next_question():
|
| 79 |
+
if game_state["current_question"] < len(question_bank):
|
| 80 |
+
return question_bank[game_state["current_question"]]
|
| 81 |
+
else:
|
| 82 |
+
return {"question": "Congratulations, you've won!", "options": [], "answer": ""}
|
| 83 |
+
|
| 84 |
+
def check_answer(answer):
|
| 85 |
+
if answer == question_bank[game_state["current_question"]]["answer"]:
|
| 86 |
+
game_state["score"] += 1
|
| 87 |
+
game_state["current_question"] += 1
|
| 88 |
+
return True
|
| 89 |
+
else:
|
| 90 |
+
return False
|
| 91 |
+
|
| 92 |
+
def use_help_line(help_line):
|
| 93 |
+
if help_line == "50:50":
|
| 94 |
+
game_state["help_lines_used"]["50:50"] = True
|
| 95 |
+
return help_lines["50:50"](question_bank[game_state["current_question"]])
|
| 96 |
+
elif help_line == "Skip":
|
| 97 |
+
game_state["help_lines_used"]["Skip"] = True
|
| 98 |
+
game_state["current_question"] += 1
|
| 99 |
+
return None
|
| 100 |
+
elif help_line == "Clue":
|
| 101 |
+
game_state["help_lines_used"]["Clue"] = True
|
| 102 |
+
return help_lines["Clue"](question_bank[game_state["current_question"]])
|
| 103 |
+
|
| 104 |
+
with gr.Blocks() as demo:
|
| 105 |
+
question = gr.Textbox(label="Question")
|
| 106 |
+
options = gr.Radio(label="Options")
|
| 107 |
+
submit = gr.Button("Submit")
|
| 108 |
+
help_line_50_50 = gr.Button("50:50")
|
| 109 |
+
help_line_skip = gr.Button("Skip")
|
| 110 |
+
help_line_clue = gr.Button("Clue")
|
| 111 |
+
score = gr.Number(label="Score")
|
| 112 |
+
result = gr.Textbox(label="Result")
|
| 113 |
+
|
| 114 |
+
submit.click(check_answer, inputs=[options], outputs=[result])
|
| 115 |
+
help_line_50_50.click(use_help_line, inputs=["50:50"], outputs=[options])
|
| 116 |
+
help_line_skip.click(use_help_line, inputs=["Skip"], outputs=[question])
|
| 117 |
+
help_line_clue.click(use_help_line, inputs=["Clue"], outputs=[result])
|
| 118 |
+
demo.load(get_next_question, inputs=[], outputs=[question, options, score])
|
| 119 |
+
|
| 120 |
+
demo.launch()
|