Ask coding questions

← Back to all posts
What wrong with sqrt() ?
FineMouche (2)

i imported math so what is the issue ?

-> fixed

so now i want know : how i can tell to python use sqrt() as math.sqrt() ?

-> answered

Answered by InvisibleOne (3224) [earned 5 cycles]
View Answer
Comments
hotnewtop
InvisibleOne (3224)

Import sqrt() from math, like this:

from math import sqrt

and then you can

sqrt(25)

Or else you have to do:

import math

math.sqrt(20)

Or if you really want to you can do this

from math import sqrt as whatever_you_want

whatever_you_want(25)

And if you want everything from math, just put * which imports everything.

from math import *
Coder100 (18925)

You didn't import it all, you must do:

from math import *
sqrt(...)

otherwise, it is bound to math, like: math.sqrt(...)

ruiwenge2 (1191)

you have to use math.sqrt()

FineMouche (2)

ok its math.sqrt ...

how i can tell to python use sqrt() as math.sqrt() ?

ruiwenge2 (1191)

@FineMouche you can set a variable like this:

sqrt = math.sqrt