Distance

Python

Public Domain

Simple application of the Pythagorean Theorem in Python

Download (right click, save as, rename as appropriate)

Embed

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/usr/bin/python

a = input("x1: ")
b = input("y1: ")
c = input("x2: ")
d = input("y2: ")

def distance(x1, y1, x2, y2):
	xdis = x2 - x1
	ydis = y2 - y1
	hyp = (ydis**2 + xdis**2)
	hyp = hyp**0.5
	return hyp

print distance(a,b,c,d)