Reading Time: 1 minutes
Distance between points on Cartesian Plane in Python
Given two points represented by coordinates i.e. (x1, y1) & (x2, y2), write a Python program to calculate distance between points on Cartesian Plane. The distance is calculated as square root of summation of squares of difference between corresponding x and y values.
import math pointOne = (3,0) pointTwo = (0,4) distanceBetweenPoints = math.sqrt( ( (pointOne[0]-pointTwo[0]) ** 2 ) + ( (pointOne[1]-pointTwo[1]) **2 ) ) print(distanceBetweenPoints) # 5.0