求助,无法运算
Topic source已解决。print 位置的问题。
# -*- coding: utf-8 -*-
import math
a = float(input('Please input a'))
b = float(input('Please input b'))
c = float(input('Please input c'))
def quadratic(a, b, c):
if (a==0):
return 'value of a cannot be 0'
else :
derta = b**2 - 4*a*c
if (derta >= 0):
x1 = (-b + math.sqrt(derta))/(2*a)
x2 = (-b - math.sqrt(derta))/(2*a)
return x1, x2
else :
return 'Wrong Number!'
print (quadratic(a, b, c))
- 1
GhZicE-奇
运行结果如下: Please input a0 Please input b0 Please input c0
Process finished with exit code 0
代码如下: