(Finding the values of x in a quadratic equation w/o importing.) Whenever I run the program, Python stops at discriminant = (b ** 2) - 4(a * c)
and shows TypeError: 'int' object is not callable. What's wrong?
#------SquareRootDefinition---------#
def Square_Root(n, x):
if n > 0:
y = (x + n/x) / 2
while x != y:
x = y
return Square_Root(n, x)
else:
if abs(10 ** -7) > abs(n - x ** 2):
return y
elif n == 0:
return 0
else:
return str(int(-n)) + "i"
#----------Quadratic Equation--------------#
a = input("Enter coefficient a: ")
while a == 0:
print "a must not be equal to 0."
a = input("Enter coefficient a: ")
b = input("Enter coefficient b: ")
c = input("Enter coefficient c: ")
def Quadratic(a, b, c):
discriminant = (b ** 2) - 4(a * c)
if discriminant < 0:
print "imaginary"
elif discriminant >= 0:
Sqrt_Disc = Square_Root(discriminant)
First_Root = (-b + Sqrt_Disc) / (2 * a)
Second_Root = (-b - Sqrt_Disc) / (2 * a)
return First_Root, Second_Root
X_1, X_2 = Quadratic(a, b, c)