这里哪里有语法错误啊
请大神看一看 第8和9行,括号没有成对。 本帖最后由 jackz007 于 2021-10-11 22:27 编辑出错的第九行代码与图片中贴出的代码不符啊!
import math
a = float(input('please enter the value of a : '))
b = float(input('please enter the value of b : '))
c = float(input('please enter the value of a : '))
delta = b * b - 4 * a * c
if int(delta) > 0:
x1 = (-b + math . sqrt(delta)) / (2 * a)
x2 = (-b - math . sqrt(delta)) / (2 * a)
print('the equation has two result!')
print('x1 = ' , x1)
print('x2 = ' , x2)
elif int(delta) == 0:
x = (-b) / (2 * a)
print('the equation has only one result!')
print('x = ' , x)
else:
print('the equation has no result!')
浮点数最好先转换成整型数后再判断相等。
页:
[1]