LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Square root in python? (https://www.linuxquestions.org/questions/programming-9/square-root-in-python-633509/)

raskol 04-06-2008 03:28 PM

Square root in python?
 
how do i get the square root of a number in python?

colucix 04-06-2008 03:37 PM

The function is sqrt from module math
Code:

>>> from math import sqrt
>>> n = sqrt(64)
>>> print n
8.0


Tischbein 04-06-2008 03:42 PM

4 ** 0.5

(or was it 4 * 0.5? Just kidding...!)

raskol 04-06-2008 04:13 PM

what is the adv/dadv of those different methods?

ghostdog74 04-06-2008 07:56 PM

** is an internal operator. sqrt is a function that you need to import from math module. can you guess which is "faster"?


All times are GMT -5. The time now is 01:11 AM.