Home > other >  Root operation mistakes in Python
Root operation mistakes in Python

Time:10-07

Just starting at Python, write a few lines of code, made a a yuan quadratic equation, the code is as follows:
The import math
Def quadratic (a, b, c) :
Y1=(a - b + math.h SQRT (b ^ 2-4 * a * c))/(2 * a)
Y2=(a - b - math. SQRT (b ^ 2-4 * a * c))/(2 * a)
Print (y1, y2)
Quadratic (2, 0, - 8)

Running result is 2.03100960115899 2.03100960115899

In theory should be 2.0 and 2.0, which a great god can explain?
  • Related