+ 3

python math

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

31st Oct 2020, 9:47 AM
shahrbanoogolmohamadi
13 ответов
+ 11
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!
31st Oct 2020, 11:21 AM
Lothar
Lothar - avatar
+ 7
😁 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
31st Oct 2020, 10:48 AM
Shadoff
Shadoff - avatar
+ 5
make sure you installed math before you use it
31st Oct 2020, 9:55 AM
Med Amine Fh
Med Amine Fh - avatar
+ 4
Are you running this on SoloLearn or somewhere else?
31st Oct 2020, 9:52 AM
Russ
Russ - avatar
+ 3
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
31st Oct 2020, 10:05 AM
Evans Enweremadu
Evans Enweremadu - avatar
+ 2
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.
31st Oct 2020, 9:59 AM
Evans Enweremadu
Evans Enweremadu - avatar
+ 2
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.
1st Nov 2020, 3:18 PM
Nikhil
+ 2
You can write 2⁴ as 2**4 in python
1st Nov 2020, 7:42 PM
Atoms~⚛
Atoms~⚛ - avatar
+ 1
If you are using an IDE then probably you have to install math first. Just go to pip and write pip install math.
2nd Nov 2020, 9:03 AM
Md. Faheem Hossain
Md. Faheem Hossain - avatar
0
Russ no on pc.python 3.4.3
31st Oct 2020, 9:55 AM
shahrbanoogolmohamadi
0
Evans Enweremadu python 3.4.3 should I use another version
31st Oct 2020, 10:01 AM
shahrbanoogolmohamadi
0
Under help-python docs-modules-math to see if it has pow included
31st Oct 2020, 10:06 AM
Evans Enweremadu
Evans Enweremadu - avatar
0
To use pow(power or exponentiation) you dont need to import anything ! Simply write :- print(pow(num1 , num2))
1st Nov 2020, 5:38 PM
Shubhank Gupta
Shubhank Gupta - avatar