Hello, I am just getting started with programming and figured the best way to learn was to get my hands dirty instead of memorizing tons of syntax. I made a very simple Quadratic Equation solver and I'm getting a strange answer at the end.
Here is my code:
Everything works fine until I get the answer. Here is it running:
print ("Today we will be solving your quadratic equations")
# Ask the user for values A,B,and C.
a = input ("What is your A value?")
b = input ("What is your B value?")
c = input ("What is your C value?")
#Now convert the values to the "int" type.
a = int(a)
b = int(b)
c = int(c)
#Now we need to find the descriminant.
dis = (b**2) - (4*a*c)
dis = dis**0.5
#Next, we need to evaluate the answers.
ans1 = (-1*b) + dis
ans1 = ans1 / (2*a)
ans2 = (-1*b) - dis
ans2 = ans2 / (2*a)
#Finally we print the answers.
Today we will be solving your quadratic equations
What is your A value?2
What is your B value?2
What is your C value?2
I assume that I could float the decimals, but what is confusing me is why is not adding/subtracting the numbers. Also the j after the discriminant. Could someone please explain why the j is there, and how to get rid of it? Also why it isn't adding/subtracting the answers.