i need it to be able to handle numbers like 2.31 and -12.9 for example so i set it as float if im correct
current code is this,it still fails
current code is this,it still fails
import math print ("Ax*2+Bx+C=0") print ("what is your A?") (a) = input('my a is: ') print ("what is your B?") (b) = input('my b is: ') print ("what is your C?") (c) = input('my c is: ') print ("calculating") float(a) float(b) float(c) b2 = float(b)*float(b) float(b2) d = float(b2)-4*float(a)*float(c) float(d) sqd = math.sqrt(d) x1a = float(-b)+float(sqd) float(x1a) x2a = float(-b)-float(sqd) float(x2a) ax2 = float(a)*2 float(ax2) x1 = float(x1a)/float(ax2) float(x1) x2 = float(x2a)/float(ax2) float(x2) print ("your X1 is " + x1 + "your X2 is") + x2 print ("your discriminant is" + d )error here
Error:Traceback (most recent call last):
File "math.py", line 18, in <module>
x1a = float(-b)+float(sqd)
TypeError: bad operand type for unary -: 'str'