@@ -61,40 +61,57 @@ def ask_question(self):
6161 def get_score (self ):
6262 return self .score
6363
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 = '' ):
6865 if question_one_value .lower ()== 'python' :
6966 self .score += 1
7067 print ('correct' )
7168 else :
7269 print ('Wrong Answer1' )
7370 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 ):
7674 if question_two_value .lower ()== 'yes' :
7775 self .score += 1
7876 print ('correct' )
7977 else :
8078 print ('Wrong Answer2' )
8179 print ('correct answer is yes ' )
80+ return True if question_two_value .lower ()== 'yes' else False
8281
83- question_three_value = question_three . get ()
82+ def validate_question_three ( self , question_three_value ):
8483 if question_three_value .lower ()== 'no' :
8584 self .score += 1
8685 print ('correct' )
8786 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
9090
91- question_four_value = question_four . get ()
91+ def validate_question_four ( self , question_four_value ):
9292 if question_four_value .lower ()== 'yes' :
9393 self .score += 1
9494 print ('correct' )
9595 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+
98115
99116 print ('Thankyou for Playing the Hacktoberfest quiz game, you attempted' ,self .score ,"questions correctly!" )
100117 mark = (self .score / self .total_questions )* 100
0 commit comments