Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

Whenever I try to use any of the built-in functions of Python's exponentiation and logarithms module, I get an error like this:

NameError: name 'sqrt' is not defined

I have tried using math.sqrt(4), sqrt(4) and sqrt(4.0), but none of them works. The exception is pow, which works as it's supposed to. This is really strange and I'm not sure what's wrong.

1 Answer

0 votes
by (106k points)

In python, pow is built into the language. The problem is that you haven't imported math.

Try this:

import math 

math.sqrt(9)

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
1 answer
asked Feb 25, 2021 in Python by laddulakshana (16.4k points)
0 votes
1 answer
asked Jan 12, 2021 in Python by ashely (50.2k points)
0 votes
1 answer

Browse Categories

...