from math import *
a = input("A= ")
b = input("B= ")
c = input("C= ")
d = b*b-(4*a*c)
print "The discriminent is: %s!" %d
if d >= 0:
x1 = (0-b+sqrt(d))/2*a
x2 = (0-b-sqrt(d))/2*a
print "First answer is: %s!" %x1
print "Second answer is: %s!" %x2
else:
print "X can't be resolved!"
工作完全正常,直到我嘗試了這些參數。TypeError不受支持的操作數類型
A= 0,5
B= -2
C= 2
然後打印出來,這
Traceback (most recent call last):
File "C:/Users/Mathias/Documents/Projects/Skole/project/test/Math.py", line 9, in <module>
d = b*b-(4*a*c)
TypeError: unsupported operand type(s) for -: 'int' and 'tuple'
我似乎無法弄清楚如何解決這個問題,有人可以幫我嗎?
再試一次,但更換''0,5'by 0.5' – Ronald 2014-10-08 11:26:18