Discuss / Python / 自己动手

自己动手

Topic source

木子木

#1 Created at ... [Delete] [Delete and Lock User]
import mathdef quadratic(a,b,c):    delta= b * b - 4 * a * c    if delta<0:        print("一元二次方程无实根")    elif delta==0:        x= -b/(2*a)        print(f"一元二次方程有唯一实根{x}")    else:        x1= (-b + math.sqrt(delta)) / (2 * a)        x2= (-b - math.sqrt(delta)) / (2 * a)        print(f"一元二次方程实根分别为:{x1}、{x2}")d=int(input())while d==0:    print("请重新输入d的值:")    d = int(input())e=int(input())f=int(input())quadratic(d,e,f)

  • 1

Reply