for i in range(1,5): if i%2==0: print(i) break
举一反三
- for i in range(4): if i%2==0: print(i) break print(i) 结果是
- 下列语句的执行结果是() 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
- 下列程序的执行结果是( ).for i in range(2): print(i,end=' ' )for I in range(4,6): print(I,end=' ' ) A: 2 4 6 B: 0 1 2 4 5 6 C: 0 1 0 1 2 3 D: 0 1 4 5
- 编写一段代码使用for循环输出1~10之内的奇数,以下哪些选项的结果是正确的?( ) A: for i in range(10): if i % 2 == 1: print(i) B: for i in range(9): if i % 2 == 0: print(i) C: for i in range(11): if i % 2 == 1: print(i) D: for i in range(12): if i % 2 = 0: print(i)
- 下列程序段的输出结果是___________。for i in range(5):if i%2 == 0:print(i)else:print(i)