python - Simple Quadratic and Linear Equation Calculator -
I have difficulties with a simple linear and quadratic equation calculator, quadratic works, but it does not linear Float responds, but for some reason this is always some number and then 0. For example: if I want to solve 2x + 13 = 0 , then answer - 7.0 , although this should be -6.5 . I think it's up to the top (roof) for some reason I'm pretty sure I have some syntax error, but I can not find it. Any suggestions for how to solve this problem? Thanks for your help.
import math a, b, c = input ("Enter coefficient of A, B and C. separated by commm") d = b ** 2-4 * A = c # Discrimination if any == 0: x = -c / b # liner equation x = float (x) b = float (b) c = float (c) print "is a solution of this linear equation:", x alife de & Lt; 0: print "There is no real solution for this quadratic equation" Alif D == 0: x = (-b + math.sqrt (d)) / (2 * A) print "This is a solution of quadratic equation:" , X else: x1 = (-b + math.sqrt (d)) / (2 * a) x2 = (-b-math.sqrt (d)) / (2 * a) print "two solutions of this quadratic equation Are: "x1," and ", x2
X = - C / B - If both c and b are integers, the result will also be rounded as an integer.
x = -c / float (b)
Comments
Post a Comment