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
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
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
"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)
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
>> 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/
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
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
>
>
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
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
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
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
12 matches
Mail list logo