Apr-24-2017, 02:04 PM
trying to make a script that solves a simple math problem (example x(2)+4x-2=0)
however i get this error and can't find why i get it,i went from python 2 to 3 and had to add () to the print commands ,even if i change input to raw_input and try it in python 2 i get the same error
here is my code
however i get this error and can't find why i get it,i went from python 2 to 3 and had to add () to the print commands ,even if i change input to raw_input and try it in python 2 i get the same error
here is my code
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")
b2 = b*b
d = b2-4*a*c
sqd = math.sqrt(d)
x1a = -b+sqd
x2a = -b-sqd
ax2 = a*2
x1 = x1a/ax2
x2 = x2a/ax2
print ("your X1 is ") + x1 + ("your X2 is") + x2
print ("your discriminant is") + dhere is the errorError: Traceback (most recent call last):
File "math.py", line 10, in <module>
b2 = b*b
TypeError: can't multiply sequence by non-int of type 'str'
