1 import math #调用math库 2 3 def distance(x1,y1,x2,y2): #定义距离函数,4个参数 4 dx=x2-x1 5 dy=y2-y1 6 dsquared=dx**2+dy**2 #定义dsquared 7 result=dsquared**0.5 8 return(result) 9 10 def area(radius): 11 A=math.pi*radius**2 12 return(A) 13 14 def circlearea(xc,yc,xp,yp): 15 radius=distance(xc,yc,xp,yp) 16 result=area(radius) 17 return(result)
时间: 2024-10-07 11:29:47