@@ -61,40 +61,57 @@ def ask_question(self):
61
61
def get_score (self ):
62
62
return self .score
63
63
64
- def evaluate (self ):
65
- self .score = 0
66
-
67
- question_one_value = question_one .get ()
64
+ def validate_question_one (self , question_one_value = '' ):
68
65
if question_one_value .lower ()== 'python' :
69
66
self .score += 1
70
67
print ('correct' )
71
68
else :
72
69
print ('Wrong Answer1' )
73
70
print ('correct answer is python ' )
74
-
75
- question_two_value = question_two .get ()
71
+ return True if question_one_value .lower ()== 'python' else False
72
+
73
+ def validate_question_two (self , question_two_value ):
76
74
if question_two_value .lower ()== 'yes' :
77
75
self .score += 1
78
76
print ('correct' )
79
77
else :
80
78
print ('Wrong Answer2' )
81
79
print ('correct answer is yes ' )
80
+ return True if question_two_value .lower ()== 'yes' else False
82
81
83
- question_three_value = question_three . get ()
82
+ def validate_question_three ( self , question_three_value ):
84
83
if question_three_value .lower ()== 'no' :
85
84
self .score += 1
86
85
print ('correct' )
87
86
else :
88
- print ('Wrong Answer3' )
89
- print ('correct answer is no ' )
87
+ print ('Wrong Answer2' )
88
+ print ('correct answer is no' )
89
+ return True if question_three_value .lower ()== 'no' else False
90
90
91
- question_four_value = question_four . get ()
91
+ def validate_question_four ( self , question_four_value ):
92
92
if question_four_value .lower ()== 'yes' :
93
93
self .score += 1
94
94
print ('correct' )
95
95
else :
96
- print ('Wrong Answer4' )
97
- print ('correct answer is yes ' )
96
+ print ('Wrong Answer2' )
97
+ print ('correct answer is yes' )
98
+ return True if question_four_value .lower ()== 'yes' else False
99
+
100
+ def evaluate (self ):
101
+ self .score = 0
102
+
103
+ question_one_value = question_one .get ()
104
+ self .validate_question_one (question_one_value = question_one_value )
105
+
106
+ question_two_value = question_two .get ()
107
+ self .validate_question_two (question_two_value = question_two_value )
108
+
109
+ question_three_value = question_three .get ()
110
+ self .validate_question_three (question_three_value = question_three_value )
111
+
112
+ question_four_value = question_four .get ()
113
+ self .validate_question_four (question_three_value = question_four_value )
114
+
98
115
99
116
print ('Thankyou for Playing the Hacktoberfest quiz game, you attempted' ,self .score ,"questions correctly!" )
100
117
mark = (self .score / self .total_questions )* 100
0 commit comments