python math | Sololearn: Learn to code for FREE!


python math

from math import pow python returns an error:name math is not defined what is the problem?

10/31/2020 9:47:56 AM


13 Answers

New Answer


banoo , as you can see, it is always a good idea to prepare a question for q&a well. Provide the complete code, not only one line. Also read the error message carefully, it indicates the line number where the problem occurs. Doing so, saves us a lot of going back and forth and many unnecessary enquiries. Thanks!


😁 how did you imported? from math import pow this will give an error math not defined: print(math.pow(2,3)) this will not: print(pow(2,3)) if you wanna use with main module name like: module.function() Just: import module


make sure you installed math before you use it


Are you running this on SoloLearn or somewhere else?


banoo, no there's no need. Math should be a pre-installed module for python 3.x. Check your python module index to see if math is included


Hey, banoo. What version of python do you use? Also, there's actually no need to import pow. You can just use pow() directly in python.


If you are doing it in SOLOLEARN, it will give an error , because math module is not imported . When you try in your PC , again it gives same , that means you have to install the library in to your machine. So rectify it.


You can write 2⁴ as 2**4 in python


If you are using an IDE then probably you have to install math first. Just go to pip and write pip install math.


Russ no on pc.python 3.4.3


Evans Enweremadu python 3.4.3 should I use another version


Under help-python docs-modules-math to see if it has pow included


To use pow(power or exponentiation) you dont need to import anything ! Simply write :- print(pow(num1 , num2))