Discuss / Python / 交作业improvment

交作业improvment

Topic source

import math

def quadratic(a, b, c):

    if a==0:

        if b==0:

            print ('It cannot both be zero !')

        else:

            return -c/b

    elif b**2-4*a*c<0:

        return 'No answer'

    else:

        q1=math.sqrt(b**2-4*a*c)

        x1=( -b+q1)/(2*a)

        x2=( -b-q1)/(2*a)

        return x1,x2

quadratic(0, 0, 1)


  • 1

Reply