Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 8 Online
OpenStudy (anonymous):

On Problem Set 2 Question 1, I can't get the inter active mode to print out the function. If I input something like: >>> poly = (0.0, 0.0, 5.0, 9.3, 7.0) >>> x = -13 >>> print evaluate_poly(poly, x) 180339.9 But instead it says something like Traceback (most recent call last): File "", line 1, in print evaluate_poly(poly, x) NameError: name 'evaluate_poly' is not defined Not sure what I'm doing wrong, any thoughts? Its probably something ridiculously simple!

OpenStudy (rsmith6559):

Assuming that you posted the entire session, either evaluate_poly() will need to be typed in before those three lines, or it will need to imported from a file: from whateverFile import evaluate_poly

OpenStudy (anonymous):

Ok, well that is good to know. Python is still a little weird to me with this whole interactive mode. I wasn't importing or typing in the code for the evaluate_ploy(). Once I did that it worked like a charm! Thanks!

OpenStudy (rsmith6559):

During testing/debugging, trying something new, the interactive is great. It's actually a shell environment, separate from writing a file and then executing it.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!