python代码求解释

发布网友 发布时间: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,是一个集合成员迭代操作。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com