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

I have imported 'from math import *' and tried to run x = math.e print x (indented properly) but it says error name 'math' is not defined. Using function from Python Standard Library http://docs.python.org/library/math.html

OpenStudy (owlfred):

Hoot! You just asked your first question! Hang tight while I find people to answer it for you. You can thank people who give you good answers by clicking the 'Good Answer' button on the right!

OpenStudy (anonymous):

try "import math" instead of "from math import *"

OpenStudy (vaboro):

if "import math" is used instead of "from math import *" the functions of the math module will have to be called as methods of the math class (excuse me if I accidentally misuse terminology... I'm just reading "how to think like a computer scientist" and try to apply the concepts I learned in the book), for example, instead of writing sqrt() one would have to write math.sqrt() and so on...

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!