-
Notifications
You must be signed in to change notification settings - Fork 0
/
jeopardy.py
135 lines (121 loc) · 3.88 KB
/
jeopardy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import random
# Define the questions and answers
jeopardy_data = {
"Science": [
{
"question": 'What planet is known as the "red planet"?',
"answer": "Mars",
"points": 100,
},
{
"question": "What is the chemical symbol for water?",
"answer": "H2O",
"points": 200,
},
],
"New Moon": [
{
"question": "Who is New Moon's partner?",
"answer": "Boothill",
"points": 200,
},
{
"question": "What is New Moon's ranking within his group?",
"answer": "4",
"points": 300,
},
{
"question": "Who is New Moon's brother?",
"answer": "Misha",
"points": 300,
},
{
"question": "New Moon is an Emanator of-?",
"answer": "Harmony",
"points": 200,
},
{
"question": "What is New Moon's bounty (insert as a number)?",
"answer": "2,190,000",
"points": 400,
},
{
"question": "New Moon is half human half-?",
"answer": "Dragon",
"points": 100,
},
],
"Literature": [
{"question": "Who wrote '1984'?", "answer": "George Orwell", "points": 100},
{
"question": "Who is the author of 'To Kill a Mockingbird'?",
"answer": "Harper Lee",
"points": 200,
},
],
"Honkai Star Rail": [
{
"question": "What is the name of all playable paths in Honkai Star Rail?",
"answers": [
"Abundance",
"Erudition",
"Hunt",
"Nihility",
"Harmony",
"Destruction",
"Preservation",
],
"points": 200,
},
{
"question": "What are the names of all planets you can visit in Honkai Star Rail? (As of 2.1.5)",
"answers": [
"Herta Space Station, Jarilo-VI",
"The Xianzhou Luofu",
"Penacony",
],
"points": 100,
},
],
}
# Function to ask a question and check the answer
def ask_question(question_data):
print(f"Question: {question_data['question']} (Points: {question_data['points']})")
answer = input("Your answer: ").strip()
if answer.lower() == question_data["answer"].lower():
print("Correct!")
return question_data["points"]
else:
print(f"Wrong! The correct answer was: {question_data['answer']}")
return 0
# Main game loop
def play_jeopardy():
score = 0
while True:
# Display categories
print("Categories:")
for i, category in enumerate(jeopardy_data.keys(), 1):
print(f"{i}. {category}")
# Choose a category
category_choice = int(input("Choose a category (1/2/3 or 0 to quit): "))
if category_choice == 0:
break
category = list(jeopardy_data.keys())[category_choice - 1]
# Choose a question from the category
questions = jeopardy_data[category]
question_data = random.choice(questions)
questions.remove(question_data) # Remove the question to avoid repetition
# Ask the question and update the score
score += ask_question(question_data)
# Check if all questions in the category have been asked
if not questions:
del jeopardy_data[category]
print(f"All questions in {category} have been asked.")
# Check if all categories are exhausted
if not jeopardy_data:
print("All questions in all categories have been asked.")
break
print(f"Your current score is: {score}")
print(f"Game over! Your final score is: {score}")
# Start the game
play_jeopardy()