I have a set of coordinates (x,y) and im trying to write a function that generates the centroid of them, so far I keep getting errors, here is the code I have so far:
def get_centroid(x,y):
centroid = (sum(x)/len(x),sum(y)/len(y))
x=[3,1,5,7,4,-2]
y=[0,-3,-3,1,5,2]
thank you for any help or suggestions.
您的方法可以使用,但请记住要return
结果,并注意用空列表除以零。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.