# -*- coding:utf-8 -*-
def quadratic(a,b,c):
import math
if b**2-4*a*c < 0:
return'该方程无解'
elif b**2-4*a*c == 0:
x = -b/(2*a)
print('该方程只有一个解,该解为%-6.3f'%x)
else:
x = (-b+math.sqrt(b**2-4*a*c))/(2*a)
y = (-b-math.sqrt(b**2-4*a*c))/(2*a)
print('该方程有两个解,分别为%-6.3f和%-6.3f'%(x,y))
调用时报错
from what.quadratic import quadratic
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "..\what\quadratic.py", line 7
return -b/(2*a)
^
TabError: inconsistent use of tabs and spaces in indentation
求助大佬指点!
解释器报错提示的缩进有问题
Sign in to make a reply
清寒藏韵
# -*- coding:utf-8 -*-
def quadratic(a,b,c):
import math
if b**2-4*a*c < 0:
return'该方程无解'
elif b**2-4*a*c == 0:
x = -b/(2*a)
print('该方程只有一个解,该解为%-6.3f'%x)
else:
x = (-b+math.sqrt(b**2-4*a*c))/(2*a)
y = (-b-math.sqrt(b**2-4*a*c))/(2*a)
print('该方程有两个解,分别为%-6.3f和%-6.3f'%(x,y))
调用时报错
from what.quadratic import quadratic
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "..\what\quadratic.py", line 7
return -b/(2*a)
^
TabError: inconsistent use of tabs and spaces in indentation
求助大佬指点!