Discuss / Python / 作业

作业

Topic source

好学者

#1 Created at ... [Delete] [Delete and Lock User]
import mathdef quadratic(a, b, c):    if a==0:        x1=(-c)/b        x2=(-c)/b        return x1,x2    elif (b*b-4*a*c)<0:        return"方程无解"    elif (b*b-4*a*c) > 0:        m = math.sqrt(b * b - 4 * a * c)        x1 = (-b + m) / (2 * a)        x2 = (-b - m) / (2 * a)        return x1, x2    else:        x1 =(-b)/(2*a)        x2 =(-b)/(2*a)    return x1,x2a,b,c=map(int,input().split())print(quadratic(a, b, c))

  • 1

Reply