[Tutor] sqrt?

Emile van Sebille emile at fenx.com
Sun Apr 25 10:09:22 CEST 2010


On 4/24/2010 9:00 PM Steven D'Aprano said...
> On Sun, 25 Apr 2010 01:00:50 pm Kirk Z Bailey wrote:
>> Importing math does not import a sqrt function.
>
Hmm... mine's there, but hey, it's easy to roll your own:

ActivePython 2.6.1.1 (ActiveState Software Inc.) based on
Python 2.6.1 (r261:67515, Dec  5 2008, 13:58:38) [MSC v.1500 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> def sqrt(x): return x**.5
...
 >>> sqrt(4)
2.0
 >>> sqrt(12)
3.4641016151377544


Emile




More information about the Tutor mailing list