'''
需求:
求两个点之间的距离
(x1,y1)
(x2,y2)
(x1-x2)^2 + (y1-y2)^2 的平方根
1。函数
2.闭包
'''
import math
#求两个点(x1,y1),(x2,y2)之间的距离
def getDis(x1,y1,x2,y2):
return math.sqrt((x1-x2)**2 + (y1-y2)**2)
def getDisOut(x1,y1):
def getDisIn(x2,y2):
return math.sqrt((x1-x2)**2 + (y1-y2)**2)
return getDisIn()
#求点分别求(10,10),(20,20)距离原(0,0)的距离
dis = getDis(0,0,10,10)
print('(10,10)距离原点的距离为:%g'%dis1)
dis = getDis(0,0,20,20)
print('(20,20)距离原点的距离为:%g'%dis1
print('_________*8')
getDisIn = getDisOut(0,0)
dis1 = getDisIn(10,10)
print('(10,10)距离原点的距离为:%g'%dis1)
dis1 = getDisIn(20,20)
print('(20,20)距离原点的距离为:%g'%dis1