-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdist.py
29 lines (28 loc) · 829 Bytes
/
dist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
TRY IT YOURSELF
Make a function that
Calculate distance between two points.
"""
def dist(x1, x2, y1, y2):
d1 = (x2-x1)**2
d2 = (y2-y1)**2
d = (d1 + d2)**(0.5)
return d
#entryPoint
if __name__ == '__main__':
access = True
prompt = '\nPress Enter.'
prompt += '\nEnter "quit" to finish : '
while True:
exit = input(prompt).title().strip()
if(exit == "Quit"):
break
else:
try:
n1 = float(input("enter value x1 : "))
n2 = float(input("enter value y1 : "))
n3 = float(input("enter value x2 : "))
n4 = float(input("enter value y2 : "))
print("Distance between p1(x1,y1) and p2(x2,y2) : ", dist(n1, n2, n3, n4))
except:
print("Invalid Value.")