Ole Henning Jensen
tjampman at gmail.com
Sat Mar 15 20:02:08 CET 2008
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 rectangle.
>>>>> height = input ("Input height:")
>> Input height:1
>>>>> width = height*1.618
>>>>> print "Width:", width
>> Width: 1.618
>>>>> import math
>>>>> hyp_squared = height**2 + width**2
>>>>> hypotenuse = math.sqrt(hyp_squared)
>>>>> print "Diagonal:", hypotenuse
>> Diagonal: 1.90208412012
>> When I save the program then try to run the module I get an error
>> message that it is invalid.
> Please ALWAYS post the code and the traceback. Otherwise we have no way
> to easily help you.
> But I will take a guess that you saved the contents of the interactive
> session and tried to run that. That will not work, as the interactive
> session is full of >>> and results of print statements.
> So I suggest you edit the module to see if this is the case; if it is
> then remove all the junk so you just have pure Python. Run that. If you
> still get errors post the code and traceback.
Yes like Bob says you most likly saved the interactive session.
What you should do is open IDLE as usual, and *before* you start typing
you program, you should open a "new wind" from the file menu.
This should open a blank sheet, into which you can type your program,
just as you did before (but without the >>>).
When you have done that, save the file and *remember* to add ".py" to
the filename (without the quotes), then press the F5 key to run the
More information about the Tutor