Python Coordinate Distance
tuplesPractice

Store points as tuples, then measure distance

Each point is an immutable pair (x, y). Squared distance avoids floats while still comparing how far points are.

Picture this: two points

Each point is (x, y). Subtract, square, add — that’s distance².

(x1, y1)point A
→
(x2, y2)point B
→
dx, dysubtract
→
dx*dx + dy*dydistance²

In easy words

A coordinate is a fixed pair of numbers. A tuple is perfect for that: p1 = (x1, y1). Distance squared is (x1-x2)^2 + (y1-y2)^2.

Where this shows up

Maps, games, collision checks, and nearest-neighbor search all store positions as (x, y) records.

Interactive points

Point A tuple(1, 2)
Point B tuple(4, 6)
distance^2 = (1-4)^2 + (2-6)^2 = 25

Example Program

1x1, y1, x2, y2 = map(int, input().split())
2p1 = (x1, y1)
3p2 = (x2, y2)
4print((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)