以下语句不能完成1~10的累加求和的是( )
A: for i in range(11):sum+=i
B: for i in range(1,11):sum+=i
C: for i in range(10,0,-1):sum+=i
D: for i in range(10,9,8,7,6,5,4,3,2,1):sum+=i
A: for i in range(11):sum+=i
B: for i in range(1,11):sum+=i
C: for i in range(10,0,-1):sum+=i
D: for i in range(10,9,8,7,6,5,4,3,2,1):sum+=i
举一反三
- 以下语句不能完成1~10的累加求和的是( ) A: for i in range(11):sum+=i B: for i in range(1,11):sum+=i C: for i in range(10,0,-1):sum+=i D: for i in range(10,9,8,7,6,5,4,3,2,1):sum+=i
- 以下for语句中,不能完成1~10的累加功能的是A.for i in range(10,0): sum += iB.for i in range(1, 11): sum += iC.for i in range(10, 0, -1): sum += iD.for i in (10, 9, 8, 7, 6, 5, 4, 3, 2, 1): sum += i
- int i,sum=0;则执行以下语句,sum的值是。 for(i=1;i<=3;sum+=1) sum+=i;
- def func(): 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)