大家好,我正试图为我在学校的数学课编写一个二次图辅助工具
这些年来,我编写了一些其他数学工具,所有这些工具都工作得相当好。但是,当我尝试将此新代码加载到计算并运行时,它表明存在语法错误。我相信计算器(fx-CG50 AU)是在micropython上运行的,据我所知,它与micropython类似,但更区分大小写,所以我尽了最大努力,通过改变大小写,在操作符之间加空格等,使它工作了几个小时,但没有成功。任何帮助和建议都将不胜感激:)。代码如下:
print('Ax ^ 2 + Bx + C')
astr = input('A: ')
bstr = input('B: ')
cstr = input('C: ')
a = float(astr)
b = float(bstr)
c = float(cstr)
delta = (b ** 2) - (4 * a * c)
print('discriminant:', delta)
if delta == 0:
x1 = float((((-1 * b) - (delta ** 0.5) / (2 * a))))
x1int = int(x1)
if x1 == x1int:
print('x intercept: (', x1, ', 0)')
else:
sb = float(-1 * b)
sa = float(2 * a)
print('x intercept: ( (', sb, ' + sqr(', delta,'))/', sa,'), 0)')
if a > 0:
print('Nature of Graph is: Cuts the x-axis twice. Concave up.')
elif a < 0:
print('Nature of Graph is: Cuts the x-axis twice. Concave down.')
else:
print('this aint no quadratic tho')
elif delta > 0:
x1 = float((((-1 * b) - (delta ** 0.5) / (2 * a))))
x2 = float((((-1 * b) + (delta ** 0.5) / (2 * a))))
x1int = int(x1)
if x1 == x1int:
print('x intercepts: (', x1, ', 0)', ' and (', x2, ', 0)' )
else:
sb = -1 * b
sa = 2 * a
print('x intercepts: ( (', sb, ' + sqr(', delta,'))/', sa, '), 0) and ( (', sb, ' - sqr(', delta,'))/', sa, '), 0)')
if a > 0:
print('Nature of Graph is: Cuts the x-axis once. Concave up.')
elif a < 0:
print('Nature of Graph is: Cuts the x-axis once. Concave down.')
else:
print('this aint no quadratic tho')
elif delta < 0:
print('No x intercepts')
if a > 0:
print('Nature of Graph is: Lies entirely above the x-axis. Concave up. Positive definite.')
elif a < 0:
print('Nature of Graph is: Lies entirely below the x-axis. Concave down. Negative definite.')
else:
print('this aint no quadratic tho')
else:
print('error....!.')
print('y intercept: (0, ', c, ')')
xvcord = float((-1 * b) / (2 * a))
yvcord = float((a * ((xvcord) ** 2)) + (b * (xvcord)) + c)
xvcordint = int(xvcord)
yvcordint = int(yvcord)
if xvcordint == xvcord:
if yvcordint == yvcord:
print('vertex: (', xvcord, ', ', yvcord, ')')
else:
top = -1 * ( b ** 2) + ( 4 * a * c)
bot = 4 * a
print('vertex: (', xvcord, ', ',top, '/', bot, ')')
else:
if yvcordint == yvcord:
top = -1 * b
bot = 2 * a
print('vertex: (', top, '/', bot, ', ', yvcord, ')')
else:
topx = -1 * b
botx = 2 * a
topy = -1 * (b ** 2) + (4 * a * c)
boty = 4 * a
print('vertex: (', topx, '/', botx, ', ',topy, '/', boty, ')')
计算器上的错误输出为SyntaxError:无效语法。计算器没有说明这个错误发生在哪里等
它最初是在一个while循环中,带有涂鸦,但我把它们拿出来,试图把它剥离到基本的部分,这样我就可以缩小它的范围:)
提前谢谢
目前没有回答
相关问题 更多 >
编程相关推荐