[Tutor] square root

Alan Gauld alan.gauld at btinternet.com
Mon May 28 10:41:38 CEST 2007


"adam urbas" <adamurbas at hotmail.com> wrote 

> Hi all,I was just wondering how I would go about 
> performing a square root thing, for my radiacir.py program.

There is a sqrt function in the math module.

import math
print math.sqrt(9)

Math has a lot of other common mathematical functions 
in it too - logs, trigonometry etc

Or you can use the builtin pow() function to raise the value 
to the power 0.5

print pow(9,0.5)

or use exponentiation:

print 9 ** 0.5

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list