def func():
global sum
sum=0
print(sum)
for i in range(5):
sum+=1
print(sum)
func()
print(sum)
global sum
sum=0
print(sum)
for i in range(5):
sum+=1
print(sum)
func()
print(sum)
举一反三
- 智慧职教: 求1+2+……+10的程序如下,请完善: sum = 0 for i in range(11): sum = sum+ print(sum)
- 如下程序的运行结果是?sum=0 for i in range(2,101,2): sum=sum+i print(sum)
- 下列程序的输出结果是:sum = 0 def sum(i1, i2): result = 0 for i in range(i1, i2 + 1): result += i return result print sum(1, 10)
- def Sum(*p): return sum(p) print(Sum(3, 5, 8)) 运行结果是( )
- 下面代码的输出结果是 sum = 1.0 for num in range(1,4): sum+=num print(sum)