发布网友 发布时间:2022-04-24 05:29
共2个回答
热心网友 时间:2023-10-31 21:21
def calc(numbers):
sum = 0
for n in numbers:
sum = sum + n * n
print (n,numbers)
return sum
结果:
1 [1, 2, 3]
2 [1, 2, 3]
3 [1, 2, 3]
for n(循环次数),numbers(需要的处理的数组)
list2 = [1, 2, 3, 4, 5, 6, 7 ];
print (calc(list2))
list直接放numbers就可以了
热心网友 时间:2023-10-31 21:22
for element in array,是一个集合成员迭代操作。
热心网友 时间:2023-10-31 21:21
def calc(numbers):
sum = 0
for n in numbers:
sum = sum + n * n
print (n,numbers)
return sum
结果:
1 [1, 2, 3]
2 [1, 2, 3]
3 [1, 2, 3]
for n(循环次数),numbers(需要的处理的数组)
list2 = [1, 2, 3, 4, 5, 6, 7 ];
print (calc(list2))
list直接放numbers就可以了
热心网友 时间:2023-10-31 21:22
for element in array,是一个集合成员迭代操作。
热心网友 时间:2023-10-31 21:21
def calc(numbers):
sum = 0
for n in numbers:
sum = sum + n * n
print (n,numbers)
return sum
结果:
1 [1, 2, 3]
2 [1, 2, 3]
3 [1, 2, 3]
for n(循环次数),numbers(需要的处理的数组)
list2 = [1, 2, 3, 4, 5, 6, 7 ];
print (calc(list2))
list直接放numbers就可以了
热心网友 时间:2023-10-31 21:22
for element in array,是一个集合成员迭代操作。
热心网友 时间:2023-10-31 21:21
def calc(numbers):
sum = 0
for n in numbers:
sum = sum + n * n
print (n,numbers)
return sum
结果:
1 [1, 2, 3]
2 [1, 2, 3]
3 [1, 2, 3]
for n(循环次数),numbers(需要的处理的数组)
list2 = [1, 2, 3, 4, 5, 6, 7 ];
print (calc(list2))
list直接放numbers就可以了
热心网友 时间:2023-10-31 21:22
for element in array,是一个集合成员迭代操作。