Python Program to Compute the Distance Between Two Points (Pythagorean Theorem)


Write a python program to compute the distance between two points taking input from the user (Pythagorean Theorem)


import math;
x1=int(input("Enter x1--->"))
y1=int(input("Enter y1--->"))
x2=int(input("Enter x2--->"))
y2=int(input("Enter y2--->"))
d1 = (x2 - x1) * (x2 - x1);
d2 = (y2 - y1) * (y2 - y1);
res = math.sqrt(d1+d2)
print ("Distance between two points:",res);


Enter x1--->10
Enter y1--->20
Enter x2--->15
Enter y2--->19
Distance between two points: 5.0990195135927845 

Leave a Comment