Discuss / Python / 练习

练习

Topic source

Herman.

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

  • 1

Reply