如下程序实现了1-100的累乘计算sum = 0for i in range(1,101): sum+=iprint(sum)
举一反三
- sum=0for i in range(0,100): if i%2==0: sum-=i else: sum+=iprint(sum) A: -50 B: 49 C: 50 D: -49
- 下述程序的执行结果为sum = 0for i in range(100): if(i%10): continue sum+=1print(sum)
- 下面语句的执行结果是sum <- 0for(i in 1:100)sum = sum + iprint(sum) A: 5050 B: 5000 C: 5020 D: 5045
- def func(): global sum sum=0 print(sum) for i in range(5): sum+=1 print(sum) func() print(sum)
- 下面程序段的运行结果是____。s = 1: sum = 0For i = 1 To 4 s = s * i sum = sum + sNext iPrint sum A: 24 B: 33 C: 10 D: 30