尝试计算点与 (0,0) 之间的平均距离时出现语法错误

Syntax errors when trying to calculate the average distance between points and (0,0)

我正在尝试计算这些点与点 (0,0) 的平均距离。我似乎遇到了错误,我不确定问题出在哪里。以下是我所做的

coordinates = [(0,1), (3,4), (-5,12), (2,2)]

print (coordinates)

import math
def distance(x1, y1, x2, y2):
     return math.sqrt(square(x2-x1) + square(y2-y1))
def square(value):
    return value * value

distances = list(map(lambda (x,y): distance(0,0,x,y), coordinates))
average = reduce(lambda p,q: p + q, distances)/float(len(distances))
print (average)

我不断收到以下错误

File "<ipython-input-103-76dd44055d43>", line 7
    distances = list(map(lambda (x,y): distance(0,0,x,y), coordinates))
                                ^
SyntaxError: invalid syntax
import math
import numpy as np

coordinates = [(0,1), (3,4), (-5,12), (2,2)]
def distance(x1, y1, x2, y2):
     return math.sqrt(square(x2-x1) + square(y2-y1))
def square(value):
    return value * value
distances = list(map(lambda x: distance(0,0,x[0],x[1]), coordinates))
print(np.mean(distances))
5.457106781186548