为什么x^2不能运行出正确结果呢,只能用x*x
def square_of_sum(L):
sum=0
for x in L:
a=x^2
sum+=a
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
这样出来的结果不对
def square_of_sum(L):
sum=0
for x in L:
a=x^2
sum+=a
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
这样出来的结果不对
2019-01-11
举报