Generic import


#1

why we have to add import math when print math.sqrt(25) will give the same result?


#2

If you can do that then you have already imported math!

The way exercises work here, the sessions do not restart every time you submit, rather, you just add or overwrite to what's already there.

You can reset the session by refreshing the page


#3

ya I tested It again and it does not work thanks!


#4

import math
print math.sqrt(23)

why does it print the square root then ask me if i forgot to put print in the script when it worked! idk what to change.

nevermind wrong line


#5

Python doesn't know what square roots are so you have to import math. This allows you to import variables and functions and guess what, sqrt is one of those function that math imports.

Did you see that? Python said: "NameError: name 'sqrt' is not defined." Python doesn't know what square roots are—yet.


#6

from math import sqrt
math.sqrt(23)


#7

:grinning:
:slightly_smiling_face: