Discuss / Python / Daily Work

Daily Work

Topic source

无愠无殇

#1 Created at ... [Delete] [Delete and Lock User]
import math
def quadratic(a, b, c):
    tmp = (b * b - 4 * a * c)
    if tmp < 0:
        return 'ValueError'
    elif tmp == 0:
        return -b/(2*a)
    else:
        tp = math.sqrt(tmp)
        x = (-b + tp)/(2*a)
        y = (-b - tp)/(2*a)
        return x, y

adc = quadratic(5, 10, 8)
print(adc)

  • 1

Reply