0

So I'm writing this program for exercise in python :

from math import sqrt
Antwoord = 0

while Antwoord != "yes": 
    print "In many cases of Maths there will be a quadratic equation"
    print "The question is how do you solve it? Through this amazing program"
    print
    print "These equations comes in a form : ax2 + bx + c"
    print "Now lets solve yours!"

    eq_a = raw_input("What is your a value?")       #Asking values
    eq_b = raw_input("What is your b value?")
    eq_c = raw_input("What is your c value?")

    vierkantsw = (eq_b) ** 2 - 4(eq_a)(eq_c)
    teller1 = -(eq_b) + sqrt(vierkantsw)     # -b+sqrt((b)**2 -4(a)(c))
    teller2 = -(eq_b) - sqrt(vierkantsw)     # -b-sqrt((b)**2 -4(a)(c))
    noemer = 2 * eq_a                        # 2(a)

    if vierkantsw < 0 :
        print "Your equation gives no solution : insolubale"     # Vir nie-reele getal 
    else:
        total1 = float(teller1) / noemer                    # Bereken die twee oplos
        total2 = float(teller2 / noemer 
        print "The two solutions are : " + total1 + " and " + total2  
    Antwoord = raw_input("Are you finished?")                   #Vra vir looping 

So this program should calculate a quadratic equation and looping it for more control, I ran the program in the terminal as well as the editor's "run" function and both gave me the same syntax error?

    print "The two solutions are : " + total1 + " and " + total2  
        ^
SyntaxError: invalid syntax

Can somebody help me here ?

Thank you in advance!

  • try using `print ("The two solutions are : " + total1 + " and " + total2)` if you are in python 3... – venpa May 03 '14 at 07:16
  • Are you using `python 3.x`? If yes, then syntax for print has changed to `print()`. And you should try to google first,if you have got syntax errors,don'ya think? – Alok May 03 '14 at 07:17

1 Answers1

3

You're missing a closing bracket (i.e., ")") after "teller2" in the previous line.

Rory Yorke
  • 2,166
  • 13
  • 13