import math def quadratic(a, b, c): p = b**2 - 4 * a * c if p < 0: p = -p print("Result x1 = %f + %fi" % ((-b/(2 * a),math.sqrt(p)/( 2 * a)))) print("Result x2 = %f - %fi" % ((-b/(2 * a),math.sqrt(p)/( 2 * a)))) else: x1 = (-b + math.sqrt(b**2 - 4 * a * c))/(2 * a) x2 = (-b - math.sqrt(b**2 - 4 * a * c))/(2 * a) print(x1) print(x2) a = float(input("Input a's value:")) b = float(input("Input b's value:")) c = float(input("Input c's vaule:")) quadratic(a, b, c) __author__ = 'www.99cankao.com'
虚数都忘掉学没学过了
Sign in to make a reply
cnzaobao