Discuss / Python / b**2 提示错误

b**2 提示错误

Topic source

Adam常

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

终于对了

# -*- coding: utf-8 -*-
import math
def quadratic(a,b,c):
    p=b*b-4*a*c
    if p>=0 and a!=0:
        x1=(-b+math.sqrt(p))/(2*a)
        x2=(-b-math.sqrt(p))/(2*a)
        return x1,x2
    else:
        return(‘Wrong Number!')

a=float(input('Please input a'))
b=float(input('Please input b'))
c=float(input('Please input c'))
print(quadratic(a,b,c))

  • 1

Reply