[Tutor] What is wrong my code?

Matthew White mwhite3 at ttsd.k12.or.us
Fri Mar 24 22:34:25 CET 2006


Hi Hoffman,

Include the definition for hypotenuse() before it is called in your script.

Also, please include the full output from the error next time.  It helps
with figuring out the exact problem.  :)

-mtw

On Fri, Mar 24, 2006 at 01:02:45PM -0800, Hoffmann (oasf2004 at yahoo.com) wrote:
> Hello:
> 
> Could anyone, please, let me know what is wrong with
> my code (shown below)? I am getting a runtime error.
> Thanks!
> Hoffmann
> ps: The code:
> 
> #!/usr/bin/python
> 
> import math
> 
> print '''This program calculates the lenght of the
> hypotenuse of a right triangle
>     given the lenghts of the two legs as
> parameters.\n'''
>     
> leg1 = raw_input('Enter the first leg of the triangle:
> ')
> leg2 = raw_input('Enter the second leg of the
> triangle: ')
> 
> result = hypotenuse(leg1, leg2)
> 
> print 'The hypotenuse of the triangle is', result
>     
> def hypotenuse(x,  y):
>     result = math.sqrt(x**2 + y**2)
>     return result
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Matthew White - District Systems Administrator
Tigard/Tualatin School District
503.431.4128

"The greatest thing in this world is not so much where we are, but in
what direction we are moving."   -Oliver Wendell Holmes



More information about the Tutor mailing list