164. Python Program to Find the Distance Between Two Points
Mediummath
Overview
Pythagoras on a map: mix the math module with your own function.
Problem Statement
Read two points, one per line. Each line holds an x and a y, separated by a space. Write a function distance(x1, y1, x2, y2) that returns the straight-line distance between the points, and print it with 2 decimal places. For example, for 1 2 and 4 6:
Distance: 5.00
The formula is the square root of (x2 - x1) ** 2 + (y2 - y1) ** 2.
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
Two lines, each with two numbers. Example:
1 2
4 6
Output
The output for that example:
Distance: 5.00
The tests try 4 different inputs.