[Tutor] hypotenuse

Brett Wilkins lupin at orcon.net.nz
Fri Mar 14 02:10:05 CET 2008

import math



> I am in an early lesson in "A Byte of Python."  Instead of writing a
> program
> to find the area of a rectangle I thought it would be useful to write a
> program to determine the length of the diagonal of a "golden rectangle",
> which would of course equal the sq root of the sum of the squares of
> the width and height.  Here is my program:
>>>> height = input ("Height:")
> Height:1
>>>> width = input ("Width:")
> Width:1.618
>>>> int = ((height**2) + (width**2))
>>>> print int
> 3.617924
>>>> hypotenuse * hypotenuse = int
> SyntaxError: can't assign to operator
> I looked ahead in the lesson and could find no mention of square roots.
> How
> do I find the square root of an integer?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list