You forgot to specify your Python version here. ryguy7272 <ryanshu...@gmail.com> Wrote in message: > When I type 'import math', it seems like my Python recognizes this library. > Great. When I try to run the following script, I get an error, which > suggests (to me) the math library is not working correctly.
Nothing to do with the math library. It's a syntax error. And it occurs before the first call into the math library. > > Script: > import math > def main(): > print "This program finds the real solutions to a quadratic" > print > a, b, c = input("Please enter the coefficients (a, b, c): ") Ouch. input is unsafe, anot recommended. That's why python 3 renamed the raw_input function to input, eliminating the unsafe version. Nevertheless, I'll assume you understand the risks, and we'll go on with your problem. > discRoot = math.sqrt(b * b - 4 * a * c) > root1 = (-b + discRoot) / (2 * a) > root2 = (-b - discRoot) / (2 * a) > print > print "The solutions are:", root1, root2 > main() > > Error: > Traceback (most recent call last): > File "C:\Users\Ryan\Desktop\QuadraticEquation.py", line 11, in <module> > main() > File "C:\Users\Ryan\Desktop\QuadraticEquation.py", line 5, in main > a, b, c = input("Please enter the coefficients (a, b, c): ") > File "<string>", line 1 > (1,1,2): > ^ > SyntaxError: unexpected EOF while parsing The error is occurring while parsing the user's input, which should not have a colon. The smallest flaw with using input () is that user error cause strange looking exceptions. > > The last line is line 11. It seems like I need this, but that's what's > causing the error. Does anyone here have any idea what is wrong here? > > Thanks. > -- DaveA -- https://mail.python.org/mailman/listinfo/python-list