Skip to content

Commit 329f883

Browse files
More interactions )
1 parent b6c977a commit 329f883

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
import json
43
import random
54

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

18+
def get_greeting_msg(points, total_qns):
19+
ans_percentage = int((points / total_qns) * 100)
20+
result_msg = 'You got {} / {} questions!'.format(points, total_qns)
21+
if ans_percentage <= 25:
22+
return 'Not so impressive.😟 ' + result_msg
23+
elif ans_percentage <= 75:
24+
return result_msg + ' Almost! Rewatch probably? 🙄'
25+
else:
26+
return result_msg + ' TRUE GOT HEAD 🐺'
27+
1928
def start_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' or str(canPlay) == 'Y'
3746
start_quiz() if canPlay else exit(-1)

0 commit comments

Comments
 (0)