Re: [Tutor] hypotenuse

2008-03-15 Thread Ole Henning Jensen
bob gailer wrote: > Robert Childers wrote: >> I have rewritten my "hypotenuse" program as follows:>>> #This program >> calculates the width and diagonal of a golden rectangle > print "Calculate the width and diagonal of a golden rectangle." >> Calculate the width and diagonal of a golden recta

Re: [Tutor] hypotenuse

2008-03-14 Thread bob gailer
Robert Childers wrote: > I have rewritten my "hypotenuse" program as follows:>>> #This program > calculates the width and diagonal of a golden rectangle > >>> print "Calculate the width and diagonal of a golden rectangle." > Calculate the width and diagonal of a golden rectangle. > >>> height = in

Re: [Tutor] hypotenuse

2008-03-14 Thread Robert Childers
I have rewritten my "hypotenuse" program as follows:>>> #This program calculates the width and diagonal of a golden rectangle >>> print "Calculate the width and diagonal of a golden rectangle." Calculate the width and diagonal of a golden rectangle. >>> height = input ("Input height:") Input height

Re: [Tutor] hypotenuse

2008-03-14 Thread Alan Gauld
"Wolfram Kraus" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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)

Re: [Tutor] hypotenuse

2008-03-14 Thread Wolfram Kraus
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

Re: [Tutor] hypotenuse

2008-03-14 Thread Alan Gauld
>> 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. -- Alan Gauld Author of the Learn to Program web site Temorarily at: http://uk.geocities.com/

Re: [Tutor] hypotenuse

2008-03-13 Thread Brett Wilkins
import math math.sqrt(intNumber) Cheers, Brett > 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

Re: [Tutor] hypotenuse

2008-03-13 Thread John Fouhy
On 14/03/2008, Scott Kerr <[EMAIL PROTECTED]> wrote: > Hello, > > I am also new to python and programming. Since two have already posted that > you need to import math modules to do square roots, I am curious. > > Why can you not use something like: > > >>>hypotenuse = hyp_squared**1/2 > > or > >

Re: [Tutor] hypotenuse

2008-03-13 Thread Andreas Kostyrka
assert 4**0.5 == 2 More generally: nth root of x: x ** (1.0/n) Or even more generally, take the 3rd root of the square of x: x ** (2.0/3.0) And when we are already extending the scope of the mailing list to math basics: 1.0/(x**2) == x**-2 (negating the power gives the inverse.) Andreas Am

Re: [Tutor] hypotenuse

2008-03-13 Thread John Fouhy
On 14/03/2008, Robert Childers <[EMAIL PROTECTED]> wrote: > 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

Re: [Tutor] hypotenuse

2008-03-13 Thread Luke Paireepinart
Robert Childers wrote: > 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

[Tutor] hypotenuse

2008-03-13 Thread Robert Childers
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 widt