[Tutor] What am I missing??

DavidCraig@PIA.CA.GOV DavidCraig@PIA.CA.GOV
Mon, 11 Jun 2001 14:45:55 -0700


I am working through the python tutorial on "How to think like a Computer
Scientist in Python".

I know its simple but I can't find why this does not work.  This is the
distance() I have written.  Below is the error message I get.

# distance function

def distance(x1, y1, x2, y2):
    dx = x2 - x1
    dy = y2 - y1
    dsquared = dx**2 + dy**2
    result = sqrt(dsquared)
    return result



Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>> import math
>>> distance(1, 2, 4, 6)
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
    distance(1, 2, 4, 6)
NameError: name 'distance' is not defined

TIA for any assistance : ))

Dave




D. H. Craig, CSM