下列程序的输出结果是:sum = 0 def sum(i1, i2): result = 0 for i in range(i1, i2 + 1): result += i return result print sum(1, 10)
举一反三
- 下列语句的执行结果是: result = 0 i = 1 while result <; 10: result += i i += 1 if i >; 2: break print(result) A: 3 B: 5 C: 7 D: 10
- 以下代码的运行结果为 def calculate(number): result = 0 i = 1 while i <= number: result = result + i i += 1 return result result = calculate(100) print('1~100的累积和为:', result)
- $sum = 0; for($i=1;$i<=100;;++$i){ if($i%2==0){ continue; } $sum += $i; } echo '$sum ='.$sum; echo输出值为_______。 2、 $sum = 0; for($i=1;$i<=100;;++$i){ if($i%2==0){ continue; } $sum += $i; } echo '$sum ='.$sum; echo输出值为_______
- 以下代码执行的结果是:( )int i=2;int result = 0;switch (i) {case 1:result = result + i;case 2:result = result + i * 2;case 3:result = result + i * 3;}System.out.println(result); A: 0 B: 2 C: 4 D: 10
- 下列程序的输出结果是( )。main(){int i=1,sum=0;while(i<10)sum=sum+i;i++;printf("i=%d,sum=%d",i,sum);} A: i=10,sum=9 B: i=9,sum=9 C: i=2,sum=1 D: 运行出现错误