55
66root .geometry ("800x800" )
77
8- root .title ("Hacktoberfest Quiz" )
8+ root .title ("Quiz Game App " )
99
1010scrollbar = Scrollbar (root )
11- scrollbar .pack ( side = RIGHT , fill = Y )
11+ scrollbar .pack (side = RIGHT , fill = Y )
1212
13- label = Label (root ,text = "Hacktoberfest Quiz " ,width = 20 ,height = 4 ,font = ("algerian" ,15 ))
13+ label = Label (root , text = "Software Engineering Quiz " ,
14+ width = 28 , height = 4 , font = ("algerian" , 15 ))
1415label .pack ()
1516
17+
1618class Quiz :
17- print ('Welcome to the Hacktoberfest 2022 Quiz' )
18- score = 0
19- total_questions = 4
19+ print ('Welcome to the Software Engineering Quiz' )
20+ score = 0
21+ total_questions = 4
2022
2123 def __init__ (self ):
2224 # self.ask_question()
2325 pass
2426
2527 def ask_question (self ):
26- answer = input ('Are you ready to play the Quiz ? (yes/no) :' )
28+ answer = input ('Are you ready to play the Quiz ? (yes/no) :' )
2729
28- if answer .lower ()== 'yes' :
29- answer = input ('Question 1: What programming language was this quiz created in?' )
30- if answer .lower ()== 'python' :
30+ if answer .lower () == 'yes' :
31+ answer = input (
32+ 'Question 1: What programming language was this quiz created in?' )
33+ if answer .lower () == 'python' :
3134 self .score += 1
3235 print ('correct' )
3336 else :
3437 print ('Wrong Answer :(' )
35-
36-
37- answer = input ('Question 2: What is software Engineering?' )
38- if answer .lower ()== 'application of engineering principle to the design a software' :
38+
39+ answer = input ('Question 2: What is software Engineering?' )
40+ if answer .lower () == 'application of engineering principle to the design a software' :
3941 self .score += 1
4042 print ('correct' )
4143 else :
4244 print ('Wrong Answer :(' )
43-
44- answer = input ('Question 3: what does SDLC stand for?' )
45- if answer .lower ()== 'software Development Life Cycle' :
45+
46+ answer = input ('Question 3: what does SDLC stand for?' )
47+ if answer .lower () == 'software Development Life Cycle' :
4648 self .score += 1
4749 print ('correct' )
4850 else :
4951 print ('Wrong Answer :(' )
50-
51- answer = input ('Question 4: First phase of software development is:' )
52- if answer .lower ()== 'requirement ananlysi' :
52+
53+ answer = input (
54+ 'Question 4: First phase of software development is:' )
55+ if answer .lower () == 'requirement ananlysi' :
5356 self .score += 1
5457 print ('correct' )
5558 else :
5659 print ('Wrong Answer :(' )
57-
58- print ('Thankyou for Playing the Hacktoberfest quiz game, you attempted' ,self .score ,"questions correctly!" )
59- mark = (self .score / self .total_questions )* 100
60- print ('Marks obtained:' ,mark )
60+
61+ print ('Thankyou for Playing the Hacktoberfest quiz game, you attempted' ,
62+ self .score , "questions correctly!" )
63+ mark = (self .score / self .total_questions )* 100
64+ print ('Marks obtained:' , mark )
6165 print ('BYE!' )
6266
6367 def get_score (self ):
6468 return self .score
6569
66- def validate_question_one (self , question_one_value = '' ):
67- if question_one_value .lower ()== 'python' :
70+ def validate_question_one (self , question_one_value = '' ):
71+ if question_one_value .lower () == 'python' :
6872 self .score += 1
6973 print ('correct' )
7074 else :
7175 print ('Wrong Answer1' )
7276 print ('correct answer is python. ' )
73- return True if question_one_value .lower ()== 'python' else False
74-
77+ return True if question_one_value .lower () == 'python' else False
78+
7579 def validate_question_two (self , question_two_value ):
76- if question_two_value .lower ()== 'application of engineering principle to the design a software' :
80+ if question_two_value .lower () == 'application of engineering principle to the design a software' :
7781 self .score += 1
7882 print ('correct' )
7983 else :
8084 print ('Wrong Answer2' )
8185 print ('correct answer is application of engineering principle to the design a software. It is the Application of engineering principles to the design,development, and support of software and it helps to solve the challenges of low- quality software project. ' )
82- return True if question_two_value .lower ()== 'application of engineering principle to the design a software' else False
86+ return True if question_two_value .lower () == 'application of engineering principle to the design a software' else False
8387
8488 def validate_question_three (self , question_three_value ):
85- if question_three_value .lower ()== 'software development life cycle' :
89+ if question_three_value .lower () == 'software development life cycle' :
8690 self .score += 1
8791 print ('correct' )
8892 else :
8993 print ('Wrong Answer2' )
9094 print ('correct answer is software development life cycle. it is a method for designing, developing, and testing high-quality softwarte.' )
91- return True if question_three_value .lower ()== 'software development life cycle' else False
95+ return True if question_three_value .lower () == 'software development life cycle' else False
9296
9397 def validate_question_four (self , question_four_value ):
94- if question_four_value .lower ()== 'requirement ananlysis' :
98+ if question_four_value .lower () == 'requirement ananlysis' :
9599 self .score += 1
96100 print ('correct' )
97101 else :
98102 print ('Wrong Answer2' )
99103 print ('correct answer is requirement ananlysis, as based on it developer design and developed the software.' )
100- return True if question_four_value .lower ()== 'requirement ananlysis' else False
104+ return True if question_four_value .lower () == 'requirement ananlysis' else False
101105
102106 def evaluate (self ):
103107 self .score = 0
@@ -110,67 +114,74 @@ def evaluate(self):
110114
111115 question_three_value = question_three .get ()
112116 self .validate_question_three (question_three_value = question_three_value )
113-
117+
114118 question_four_value = question_four .get ()
115119 self .validate_question_four (question_four_value = question_four_value )
116120
121+ print ('Thankyou for Playing the Hacktoberfest quiz game, you attempted' ,
122+ self .score , "questions correctly!" )
123+ mark = (self .score / self .total_questions )* 100
124+ my_label .config (text = "Your score is " + str (mark ) + "%" )
125+ print ('Marks obtained:' , mark )
117126
118- print ('Thankyou for Playing the Hacktoberfest quiz game, you attempted' ,self .score ,"questions correctly!" )
119- mark = (self .score / self .total_questions )* 100
120- my_label .config (text = "Your score is " + str (mark ) + "%" )
121- print ('Marks obtained:' ,mark )
122-
123-
124-
125127
126128quiz = Quiz ()
127129
128- w1_label = Label (root ,text = "Question 1: What programming language was this quiz created in?" ,font = ("arial" ,10 ),width = 100 ,height = 4 )
130+ w1_label = Label (root , text = "Question 1: What programming language was this quiz created in?" , font = (
131+ "arial" , 10 ), width = 100 , height = 4 )
129132w1_label .pack ()
130- question_one = ttk .Combobox (root ,value = ["Python" ,"Java" ,"C++" ],width = 50 ,height = 4 )
133+ question_one = ttk .Combobox (
134+ root , value = ["Python" , "Java" , "C++" ], width = 50 , height = 4 )
131135w1_label .pack ()
132136question_one .current (0 )
133137question_one .pack ()
134138
135- w1_label = Label (root ,text = "" ,font = ("arial" ,10 ),width = 200 ,height = 4 )
139+ w1_label = Label (root , text = "" , font = ("arial" , 10 ), width = 200 , height = 4 )
136140w1_label .pack ()
137141
138- w2_label = Label (root ,text = "Question 2:What is software Engineering?" ,font = ("arial" ,10 ),width = 200 ,height = 4 )
142+ w2_label = Label (root , text = "Question 2:What is software Engineering?" , font = (
143+ "arial" , 10 ), width = 200 , height = 4 )
139144w2_label .pack ()
140- question_two = ttk .Combobox (root ,width = 50 ,height = 4 ,value = ["Designing a software" ,"Testing a software" ,"Application of engineering principle to the design a software" ,"None of the above" ])
145+ question_two = ttk .Combobox (root , width = 50 , height = 4 , value = [
146+ "Designing a software" , "Testing a software" , "Application of engineering principle to the design a software" , "None of the above" ])
141147question_two .current (0 )
142148question_two .pack ()
143149
144- w2_label = Label (root ,text = "" ,font = ("arial" ,10 ),width = 200 ,height = 4 )
150+ w2_label = Label (root , text = "" , font = ("arial" , 10 ), width = 200 , height = 4 )
145151w2_label .pack ()
146152
147153
148- w3_label = Label (root ,text = "Question 3:what does SDLC stand for?" ,font = ("arial" ,10 ),width = 200 ,height = 4 )
154+ w3_label = Label (root , text = "Question 3:what does SDLC stand for?" ,
155+ font = ("arial" , 10 ), width = 200 , height = 4 )
149156w3_label .pack ()
150- question_three = ttk .Combobox (root ,width = 50 ,height = 4 ,value = ["System Design Life Cycle" ,"Software Design Life Cycle" ,"System Development Life Cycle" ,"Software Development Life Cycle" ])
157+ question_three = ttk .Combobox (root , width = 50 , height = 4 , value = [
158+ "System Design Life Cycle" , "Software Design Life Cycle" , "System Development Life Cycle" , "Software Development Life Cycle" ])
151159question_three .current (0 )
152160question_three .pack ()
153161
154- w3_label = Label (root ,text = "" ,font = ("arial" ,10 ),width = 200 ,height = 4 )
162+ w3_label = Label (root , text = "" , font = ("arial" , 10 ), width = 200 , height = 4 )
155163w3_label .pack ()
156164
157- w4_label = Label (root ,text = "Question 4: First phase of software development is:" ,font = ("arial" ,10 ),width = 200 ,height = 4 )
165+ w4_label = Label (root , text = "Question 4: First phase of software development is:" , font = (
166+ "arial" , 10 ), width = 200 , height = 4 )
158167w4_label .pack ()
159- question_four = ttk .Combobox (root ,width = 50 ,height = 4 ,value = ["Coding" ,"Testing" ,"Design" ,"Requirement ananlysis" ])
168+ question_four = ttk .Combobox (root , width = 50 , height = 4 , value = [
169+ "Coding" , "Testing" , "Design" , "Requirement ananlysis" ])
160170question_four .current (0 )
161171question_four .pack ()
162172
163- w4_label = Label (root ,text = "" ,font = ("arial" ,10 ),width = 200 ,height = 4 )
173+ w4_label = Label (root , text = "" , font = ("arial" , 10 ), width = 200 , height = 4 )
164174w4_label .pack ()
165175
166176
167- button = Button (root ,text = "Submit" ,font = ("bell mt" ,10 ), command = quiz .evaluate )
177+ button = Button (root , text = "Submit" , font = (
178+ "bell mt" , 10 ), command = quiz .evaluate )
168179button .pack ()
169180
170181
171182# w6_label = Label(root,font=("arial",10),width=100,height=4, textvariable=quiz.get_score())
172183my_label = Label (root ,
173- text = "Score:" )
184+ text = "Score:" )
174185my_label .pack ()
175186
176187
0 commit comments