<div>I have rewritten my &quot;hypotenuse&quot; program as follows:&gt;&gt;&gt; #This program calculates the width and diagonal of a golden rectangle<br>&gt;&gt;&gt; print &quot;Calculate the width and diagonal of a golden rectangle.&quot;<br>
Calculate the width and diagonal of a golden rectangle.<br>&gt;&gt;&gt; height = input (&quot;Input height:&quot;)<br>Input height:1<br>&gt;&gt;&gt; width = height*1.618<br>&gt;&gt;&gt; print &quot;Width:&quot;, width<br>
Width: 1.618<br>&gt;&gt;&gt; import math<br>&gt;&gt;&gt; hyp_squared = height**2 + width**2<br>&gt;&gt;&gt; hypotenuse = math.sqrt(hyp_squared)<br>&gt;&gt;&gt; print &quot;Diagonal:&quot;, hypotenuse<br>Diagonal: 1.90208412012</div>

<div>&nbsp;</div>
<div>When I save the program then try to run the module I get an error message that it is invalid.</div>
<div>I have been assuming that if no &quot;invalid syntax&quot; error occurs in the shell the program should run.&nbsp; Could this problem be associated with the import math instruction?<br><br></div>
<div class="gmail_quote">On Fri, Mar 14, 2008 at 6:03 AM, Alan Gauld &lt;<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">&quot;Wolfram Kraus&quot; &lt;<a href="mailto:wolfram.kraus@fen-net.de">wolfram.kraus@fen-net.de</a>&gt; wrote in message<br>
news:frdiev$m4u$1@ger.gmane.org...<br>
<div class="Ih2E3d">&gt; Am 14.03.2008 09:40, Alan Gauld schrieb:<br>&gt;&gt;&gt;&gt; Why can you not use something like:<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; hypotenuse = hyp_squared**1/2<br>&gt;&gt;<br>&gt;&gt; And for completeness that could also be written:<br>
&gt;&gt;<br>&gt;&gt; hypotenuse = pow(hyp_squared,1/2)<br>&gt;&gt;<br>&gt;&gt; Again, without the need to import math.<br>&gt;&gt;<br>&gt; But beware of the integer divison in Python:<br>&gt;<br>&gt; &gt;&gt;&gt; pow(2,1/2)<br>
&gt; 1<br><br></div>Good catch. Applies to the ** style too.<br><br>Alan G<br>
<div>
<div></div>
<div class="Wj3C7c"><br><br>_______________________________________________<br>Tutor maillist &nbsp;- &nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</div></div></blockquote></div><br>