Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb83585e

Browse files
Directory name change
1 parent0de547f commitb83585e

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

‎gameofthrones_quiz/quiz.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"questions": [
3+
{
4+
"question":"Who was the Lord of Winterfell in the show beginning?",
5+
"options": [
6+
"Jon Snow",
7+
"Benjen Stark",
8+
"Ned Stark",
9+
"Robb Stark"
10+
],
11+
"answer":3
12+
},
13+
{
14+
"question":"Which house is the most powerful in Westeros south?",
15+
"options": [
16+
"Lannisters",
17+
"Tyrells",
18+
"Martell",
19+
"Targaryens"
20+
],
21+
"answer":1
22+
},
23+
{
24+
"question":"Who stabbed the Mad king?",
25+
"options": [
26+
"Robert Baratheon",
27+
"Ned Stark",
28+
"Jaime Lannister",
29+
"Jon Arryn"
30+
],
31+
"answer":3
32+
},
33+
{
34+
"question":"Under whose command the Lannisters won the Battle of Blackwater",
35+
"options": [
36+
"Joffrey Baratheon",
37+
"The Hound",
38+
"Tyrion Lannister",
39+
"Cersei Lannister"
40+
],
41+
"answer":3
42+
},
43+
{
44+
"question":"Who did Arya Stark meet in Bravos?",
45+
"options": [
46+
"Jon Snow",
47+
"Jacqen H'hgar",
48+
"Brienne of Tarth",
49+
"Daenerys Targaryen"
50+
],
51+
"answer":2
52+
},
53+
{
54+
"question":"What house did Ser Jorah belong to?",
55+
"options": [
56+
"Targaryen",
57+
"Freys",
58+
"Boltons",
59+
"Mormonts"
60+
],
61+
"answer":4
62+
},
63+
{
64+
"question":"How did Robb Stark die?",
65+
"options": [
66+
"Got killed in the War of the five kings",
67+
"Stabbed by his own mother Catelyn",
68+
"Killed in the Red Wedding",
69+
"Killed by his horse"
70+
],
71+
"answer":3
72+
},
73+
{
74+
"question":"Who was the daughter of Stannis?",
75+
"options": [
76+
"Princess Shireen",
77+
"Princess Lyanna",
78+
"Princess Arya",
79+
"Princess Myrcella"
80+
],
81+
"answer":1
82+
}
83+
]
84+
}

‎gameofthrones_quiz/quiz.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python3
2+
3+
importjson
4+
importrandom
5+
6+
defget_questions():
7+
questions_file=open('./quiz.json')
8+
questions_obj=json.load(questions_file)
9+
questions_file.close()
10+
returnquestions_obj['questions']
11+
12+
defprint_choices(choices):
13+
forindex,choiceinenumerate(choices):
14+
print('{}.{}'.format(index+1,choice),'\n')
15+
16+
defis_correct(ans,user_answer):
17+
returnans==str(user_answer)
18+
19+
defstart_quiz():
20+
questions=get_questions()
21+
points=0
22+
forindex,valinenumerate(questions):
23+
print(val['question'],'\n')# Question
24+
print_choices(val['options'])
25+
answer=input('Your answer(in number)?\n')
26+
ifis_correct(answer,val['answer']):
27+
print('✓')
28+
points+=1
29+
else:
30+
print('✘')
31+
print('You got {}/{} questions correct. Hooray'.format(points,len(questions)))
32+
33+
34+
if__name__=="__main__":
35+
canPlay=input('Press y/Y to play the Game of Thrones quiz 🦁\n')
36+
canPlay=str(canPlay)=='y'orstr(canPlay)=='Y'
37+
start_quiz()ifcanPlayelseexit(-1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp