Problem 164568 · easy · Phase 01 Prerequisites & Setup

Distance Between Two Points

functions · geometry · math module

Write distance(x1, y1, x2, y2) that returns the straight-line distance between the points (x1, y1) and (x2, y2), rounded to 3 decimal places.

Examples

Input:  x1 = 0, y1 = 0, x2 = 3, y2 = 4
Output: 5.0

Input:  x1 = 0, y1 = 0, x2 = 1, y2 = 1
Output: 1.414

Input:  x1 = 1, y1 = 1, x2 = 1, y2 = 1
Output: 0.0

Constraints

  • Coordinates are ints or floats with absolute value at most 10**6

Goals

  • Take four parameters and combine them in a formula
  • Use `math.sqrt` and round
Starting Python…