16、下面程序的执行结果是______________。(1275) s = 0 for i in range(1,101): s += i if i == 50: print(s) break else: print(1)
1275
举一反三
- 阅读程序,输出结果: s=0 for i in range(1,101): s = s + i print('1+2+3+…+100 = ', s)
- 如果有i=1,s=0,执行下列指令后,print(s)的结果是( )。while(i): if not (i % 3): break; else: s = s + i i = i + 1 A: 3 B: 6 C: 1 D: 0
- 下面程序的输出结果是______s = 'abc' try: for i in range(3): s[i] = 'a' print(s) except: print('Error')[/i]
- 有如下程序段:s = 0For i = 1 To 10 s = s + iNext iPrint s与上述程序段输出结果相同的程序段为( )。 A: s = 0: i = 0 While i <= 10 i = i + 1 s = s + i Wend Print s B: s = 0: i = 1 While i < 10 i = i + 1 s = s + i Wend Print s C: s = 0: i = 1 Do s = s + i i = i + 1 Loop While i < 10 Print s D: s = 0: i = 1 Do s = s + i i = i + 1 Loop Until i > 10 Print s
- 执行下列程序段后,程序的运行结果为()。 s = 1 For i = 1 To 3 For j = 0 To i - 1 s = s + s * j Next j Print s; Next i
内容
- 0
下列语句的执行结果是() a = 1 for i in range(5): if i == 2: break a += 1 else: a += 1 # print(a) A: 3 B: 5 C: 1 D: 0
- 1
程序如下 s=0 for i in range(1, 11): s=s+i i=i+1 print(s, i) 程序运行结果s和i的值分别是 A: 50,12 B: 55,10 C: 55,11 D: 50,10
- 2
程序如下 s=0 for i in range (1, 11): s=s+i i=i+1 print(s) 以上程序去掉那一语句,将不影响程序的功能 A: i=i+1 B: print(s) C: foriinrange(1,11): D: s=s+i
- 3
下列程序输出结果是( )。 i=1 s=0 while i<=3: s=s+i i=i+1 print(s) A: 1 B: 3 C: 6 D: 9
- 4
for i in range(4): if i%2==0: print(i) break print(i) 结果是