python中如何對數(shù)列中的每個(gè)數(shù)進(jìn)行平方然后求和?
x1=[12,435,23]x2=[21,42,452]x3 = map(lambda x,y:x-y,x1,x2)print x3x3_1 = map(lambda x:x**2,x3)print x3_1x3_sum = sum(x3_1)print x3_sum
python中如何對數(shù)列中的每個(gè)數(shù)進(jìn)行平方然后求和?
x1=[12,435,23]x2=[21,42,452]x3 = map(lambda x,y:x-y,x1,x2)print x3x3_1 = map(lambda x:x**2,x3)print x3_1x3_sum = sum(x3_1)print x3_sum