Discuss / Python / 学着百度着。。。

学着百度着。。。

Topic source

larefa

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

-- coding: utf-8 --

import math

def quadratic(a, b, c):

if (b**2-4*a*c)<0:
    print('此方程无解')
else:
    x1=(-b+math.sqrt((b**2-4*a*c)))/(2*a)

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

    return x1,x2

a, b, c = (int(x) for x in input().split(' '))

x1,x2=quadratic(a, b, c)

print('此方程的两个解为:') print(x1,x2)


  • 1

Reply