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

Commit329f883

Browse files
More interactions )
1 parentb6c977a commit329f883

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

‎gameofthrones_quiz/quiz.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
32
importjson
43
importrandom
54

@@ -16,6 +15,16 @@ def print_choices(choices):
1615
defis_correct(ans,user_answer):
1716
returnans==str(user_answer)
1817

18+
defget_greeting_msg(points,total_qns):
19+
ans_percentage=int((points/total_qns)*100)
20+
result_msg='You got {} / {} questions!'.format(points,total_qns)
21+
ifans_percentage<=25:
22+
return'Not so impressive.😟 '+result_msg
23+
elifans_percentage<=75:
24+
returnresult_msg+' Almost! Rewatch probably? 🙄'
25+
else:
26+
returnresult_msg+' TRUE GOT HEAD 🐺'
27+
1928
defstart_quiz():
2029
questions=get_questions()
2130
points=0
@@ -28,10 +37,10 @@ def start_quiz():
2837
points+=1
2938
else:
3039
print('✘')
31-
print('You got {}/{} questions correct. Hooray'.format(points,len(questions)))
40+
print(get_greeting_msg(points,len(questions)))
3241

3342

34-
if__name__=="__main__":
43+
if__name__=='__main__':
3544
canPlay=input('Press y/Y to play the Game of Thrones quiz 🦁\n')
3645
canPlay=str(canPlay)=='y'orstr(canPlay)=='Y'
3746
start_quiz()ifcanPlayelseexit(-1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp