Skip to content

Commit 54219ec

Browse files
Merge pull request steam-bell-92#1500 from kumudasrip/fix/math-quiz
Fix: division question handling in Math Quiz
2 parents a4869fb + 80953f7 commit 54219ec

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

games/Math-Quiz/Math-Quiz.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def generate_question(difficulty):
8686
a, b = random.randint(2, 15), random.randint(2, 15)
8787
return f"What is {a} x {b}?", a * b
8888
elif q_type == 'div':
89-
b = random.randint(2, 10)
90-
a = b * random.randint(2, 10)
91-
return f"What is {a} / {b}?", a // b
89+
b=random.randint(2,10)
90+
a=random.randint(2,100)
91+
return f"What is {a} / {b}?",round(a/b,2)
9292
elif q_type == 'negative':
9393
a = random.randint(-25, -1)
9494
b = random.randint(1, 30)
@@ -138,7 +138,10 @@ def generate_options(correct):
138138

139139
options = {correct}
140140
while len(options) < 4:
141-
fake = correct + random.randint(-15, 15)
141+
if isinstance(correct,float):
142+
fake=round(correct+random.uniform(-3,3),2)
143+
else:
144+
fake=correct+random.randint(-15,15)
142145
if fake != correct:
143146
options.add(fake)
144147
options = list(options)

0 commit comments

Comments
 (0)