Discuss / Python / 百度加自己改

百度加自己改

Topic source

-- coding: utf-8 --

import math

def quadratic(a, b, c): x1=(-b+math.sqrt(bb-4ac))/(2a) x2=(-b-math.sqrt(bb-4ac))/(2a) return(x1,x2)

def Error1(): print("错误1:二次项系数不能为0,请重新输入...")

def Error2(): print("错误2:代尔塔不能小于0,请重新输入...")

while True:
    if a!=0 and (b*b-4*a*c)>=0: 
        print(quagratic(a,b,c))
        print ("Done")
        print ("")
    else:
        if a==0:
            Error1()
        if (b*b-4*a*c)<0:
            Error2()

  • 1

Reply