View Single Post
Old Oct 30th, 2007, 10:49 PM   #16
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Quadratic Formula in Python

Your print syntax doesn't match my example. You need quotations. You need the % sign. And you need () around your variables. Syntax in programming can be understandably picky. If you follow my previous example.

    print "%s %s %s %s"%(root1r, rooti, root2r, rooti)
    print

But you got some of your variable names wrong. rooti should be root1i, same with root2i.

Then you can format it more nicely like so:

    print "%s+%si , %s+%si"%(root1r, root1i, root2r, root2i)
    print
Sane is offline   Reply With Quote