To find the distance between two points, given by the coordinates (x1, y1) and (x2, y2) by Pythagorean theorem using functions

def pt(x1,y1,x2,y2):
      x=x2-x1
      y=y2-y1
      x=x**2
      y=y**2
      d=(x+y)**(0.5)
      return d
     
x1=int(raw_input('Enter the coordinate x1: '))
x2=int(raw_input('Enter the coordinate x2: '))
y1=int(raw_input('Enter the coordinate y1: '))
y2=int(raw_input('Enter the coordinate y2: '))
k=pt(x1,y1,x2,y2)
print 'Distance between two points is : ', k
     

No comments: