[Tutor] hypotenuse

Alan Gauld alan.gauld at btinternet.com
Fri Mar 14 14:03:00 CET 2008


"Wolfram Kraus" <wolfram.kraus at fen-net.de> wrote in message 
news:frdiev$m4u$1 at ger.gmane.org...
> Am 14.03.2008 09:40, Alan Gauld schrieb:
>>>> Why can you not use something like:
>>>>
>>>>>>> hypotenuse = hyp_squared**1/2
>>
>> And for completeness that could also be written:
>>
>> hypotenuse = pow(hyp_squared,1/2)
>>
>> Again, without the need to import math.
>>
> But beware of the integer divison in Python:
>
> >>> pow(2,1/2)
> 1

Good catch. Applies to the ** style too.

Alan G 




More information about the Tutor mailing list