已采纳回答 / 鎏樧
你的格式是不是这样呀 for x in args: sum = sum + x average = sum *1.0 /len (args) return average 如果是的话,sum值只加了第一个元素,a...
2019-06-11
'''
sum =0
for i in range(101):
p=i*i
sum=sum+p
print sum
'''
'''
sum=0
L=range(101)
for i in L:
p=L[i]*L[i]
sum=sum+p
print sum
'''
'''
sum=0
n=1
while n<101:
sum=sum+n*n
n=n+1
print sum
'''
L=[]
x=1
while x<101:
L.append(x*x)
x=x+1
print sum(L)
sum =0
for i in range(101):
p=i*i
sum=sum+p
print sum
'''
'''
sum=0
L=range(101)
for i in L:
p=L[i]*L[i]
sum=sum+p
print sum
'''
'''
sum=0
n=1
while n<101:
sum=sum+n*n
n=n+1
print sum
'''
L=[]
x=1
while x<101:
L.append(x*x)
x=x+1
print sum(L)
2019-06-11
最新回答 / weixin_慕粉0518214
for程序内含有一个for循环,第一个for循环循环一次需要内部的for循环三次之后才能进行下一次循环类似于A对应的123 同时B也对应的还是123
2019-06-11
最新回答 / 同学jvj你好
import mathdef quadratic_equation(a, b, c): t = math.sqrt(b * b - 4 * a * c) return (-b + t) / (2 * a),( -b - t )/ (2 * a)print quadratic_equation(2, 3, 0)print quadratic_equation(1, -6, 5)
2019-06-09