From 2b5a8135dc47f1209103fbbb75804ffb3a82bd09 Mon Sep 17 00:00:00 2001 From: Shiven Tripathi <58358532+ShivenTripathi@users.noreply.github.com> Date: Sat, 17 Oct 2020 18:22:20 +0530 Subject: [PATCH] debug, tested --- mathgenerator/mathgen.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 90cd1ac..fda0d0e 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -535,10 +535,13 @@ def commonFactorsFunc(maxVal=100): def quadraticEquation(maxVal=100): a = random.randint(1,maxVal) c = random.randint(1,maxVal) - b = random.randint(4*a*c,4*maxVal*maxVal) + b = random.randint(round(math.sqrt(4*a*c))+1,round(math.sqrt(4*maxVal*maxVal))) - problem = "Zeros of the Quadratic Equation {a}x^2+{b}x+{c}=0".format(a,b,c) - solution = str[(-b+sqrt(b^2-4*a*c))/2*a,(-b-sqrt(b^2-4*a*c))/2*a] + problem = "Zeros of the Quadratic Equation {}x^2+{}x+{}=0".format(a,b,c) + + D = math.sqrt(b*b-4*a*c) + + solution = str([(-b+D)/(2*a),(-b-D)/(2*a)]) return problem,solution # || Class Instances