8.复习
1 n = 0
2 for i in range(1,101):
3 n += i
4 print(n)
5
6 结果是 5050
复制代码
n = 0
for i in range(1,501):
if i % 2 == 0 :
continue
if i % 2 == 1 :
n += i
print(n)
结果是 62500
复制代码
复制代码
1 sum = 0
2 n = 1
3 for i in range(1,21):
4 n *= i
5 sum += n
6 print(sum)
7
8 结果是 2561327494111820313
复制代码
1 a = [2,32,43,453,54,6,576,5,7,6,8,78,7,89]
2 a.sort()
3 print(a)
4
5 结果
6 [2, 5, 6, 6, 7, 7, 8, 32, 43, 54, 78, 89, 453, 576]
1 n = 0
2 for i in range(1,101):
3 n += i
4 print(n)
5
6 结果是 5050
复制代码
n = 0
for i in range(1,501):
if i % 2 == 0 :
continue
if i % 2 == 1 :
n += i
print(n)
结果是 62500
复制代码
复制代码
1 sum = 0
2 n = 1
3 for i in range(1,21):
4 n *= i
5 sum += n
6 print(sum)
7
8 结果是 2561327494111820313
复制代码
1 a = [2,32,43,453,54,6,576,5,7,6,8,78,7,89]
2 a.sort()
3 print(a)
4
5 结果
6 [2, 5, 6, 6, 7, 7, 8, 32, 43, 54, 78, 89, 453, 576]