Skip to content

Commit 0baa818

Browse files
committed
fixed bugs and rendered score dynamic value
1 parent 96e7285 commit 0baa818

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

GAMES/Hacktoberfest Quiz/hacktoberfest-quiz.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ def ask_question(self):
5858
print('Marks obtained:',mark)
5959
print('BYE!')
6060

61+
def get_score(self):
62+
return self.score
63+
6164
def evaluate(self):
65+
self.score = 0
66+
6267
question_one_value = question_one.get()
6368
if question_one_value.lower()=='python':
6469
self.score += 1
@@ -91,14 +96,19 @@ def evaluate(self):
9196
print('Wrong Answer4')
9297
print('correct answer is yes ')
9398

99+
print('Thankyou for Playing the Hacktoberfest quiz game, you attempted',self.score,"questions correctly!")
100+
mark=(self.score/self.total_questions)*100
101+
my_label.config(text = "Your score is " + str(mark) +"%")
102+
print('Marks obtained:',mark)
103+
94104

95105

96106

97107
quiz = Quiz()
98108

99109
w1_label = Label(root,text="Question 1: What programming language was this quiz created in? Hint: Java, C++, Python ?",font=("arial",10),width=100,height=4)
100110
w1_label.pack()
101-
question_one = ttk.Combobox(root,value=["Pyhon","Java","C++"])
111+
question_one = ttk.Combobox(root,value=["Python","Java","C++"])
102112
question_one.current(0)
103113
question_one.pack()
104114

@@ -138,7 +148,10 @@ def evaluate(self):
138148
button.pack()
139149

140150

141-
151+
# w6_label = Label(root,font=("arial",10),width=100,height=4, textvariable=quiz.get_score())
152+
my_label = Label(root,
153+
text = "Score:")
154+
my_label.pack()
142155

143156

144157
root.mainloop()

0 commit comments

Comments
 (0)