Discuss / Python / 芜湖

芜湖

Topic source

Matthew

#1 Created at ... [Delete] [Delete and Lock User]

import math

def quadratic(a,b,c):

    delta=b**2-4*a*c

    D= float(delta)

    x1 = (-b+math.sqrt(D))/2*a

    x2 = (-b-math.sqrt(D))/2*a

    if delta>=0:

        return x1, x2

    else:

        return None

x1,x2 = quadratic(1,-4,0)

print(x1,x2)

Matthew

#2 Created at ... [Delete] [Delete and Lock User]

import math

def quadratic(a,b,c):

    delta=b**2-4*a*c

    x1 = (-b+math.sqrt(delta))/(2*a)

    x2 = (-b-math.sqrt(delta))/(2*a)

    if delta>=0:

        return x1, x2

    else:

        return None

x1,x2 = quadratic(2,3,1)

print(x1,x2)


  • 1

Reply