A pretty dumb newbie question

Duncan Smith buzzard at urubu.freeserve.co.uk
Mon Dec 10 10:59:19 EST 2001


"davewesterman" <dave2206 at aol.com> wrote in message
news:20011210091906.16346.00001379 at mb-ma.aol.com...
> sqrt(x)
> Return the square root of x.
>
> >How would you calculate square root? I've tried
> >x**1/2
> >Which doesn't work
> >Anbody?
>

How about,

>>> x**(1/2.0)
2.8284271247461903

What you have will raise x to the power 1, then divide the result by 2.
Also, note the float in the denominator.  1/2 will return the floor (the
result rounded down to the nearest integer), ie 0, and x**0 is 1.

>
> *)(*()*)(*()*)(*()*)(*()*)(*()*)(*()*)(*()*)(*()*)(*()*)(*()*)(*()*)(*()*)
> (*()*)(*()*)(*()*)(*()*)(*()*)(*()*)





More information about the Python-list mailing list