Can somebody tell me why you have to have "return result" in the below program as suggested in a beginner tutorial. I ran the second listed program below without "return result" and they both give the same value in Python interpreter. What does "return result" do?
def distance(x1, y1, x2, y2):
dx = x2 - x1
dy = y2 - y1
dsquared = dx**2 + dy**2
result = math.sqrt(dsquared)
print result
dx = x2 - x1
dy = y2 - y1
dsquared = dx**2 + dy**2
result = math.sqrt(dsquared)
print result
return result
def distance(x1, y1, x2, y2):
dx = x2 - x1
dy = y2 - y1
dsquared = dx**2 + dy**2
result = math.sqrt(dsquared)
print result
Yahoo! FareChase - Search multiple travel sites in one click.
-- http://mail.python.org/mailman/listinfo/python-list