1
1
#!/usr/bin/env python3
2
-
3
2
import json
4
3
import random
5
4
@@ -16,6 +15,16 @@ def print_choices(choices):
16
15
def is_correct (ans ,user_answer ):
17
16
return ans == str (user_answer )
18
17
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
+
19
28
def start_quiz ():
20
29
questions = get_questions ()
21
30
points = 0
@@ -28,10 +37,10 @@ def start_quiz():
28
37
points += 1
29
38
else :
30
39
print ('✘' )
31
- print ('You got {}/{} questions correct. Hooray' . format (points ,len (questions )))
40
+ print (get_greeting_msg (points ,len (questions )))
32
41
33
42
34
- if __name__ == " __main__" :
43
+ if __name__ == ' __main__' :
35
44
canPlay = input ('Press y/Y to play the Game of Thrones quiz 🦁\n ' )
36
45
canPlay = str (canPlay )== 'y' or str (canPlay )== 'Y'
37
46
start_quiz ()if canPlay else exit (- 1 )