#An illustration of functions with parameters and return value. #The function dist returns the distance between two points whose #co-ordinates are (x1,y1) and (x2,y2). The main program (the #function dist_demo) prompts the user to enter the coordinates #of two points and prints the distance between them. #The important thing here is that the dist function can be #used as a general purpose tool by many other functions: #It contains no input and output itself, and communicates #with the function that calls it only through the parameters #and return values. def dist(x1,y1,x2,y2): xdiff=x1-x2 ydiff=y1-y2 return sqrt(xdiff**2+ydiff**2) def dist_demo(): a=input("Enter x coordinate of first point") b=input("Enter y coordinate of first point") c=input("Enter x coordinate of second point") d=input("Enter y coordinate of second point") print "The distance is "+str(dist(a,b,c,d))