智慧职教: 以下代码的输出结果为: for i in range(10): if i%2 != 0: continue print(i)
举一反三
- 将300~400不能被3整除的数输出。下列哪段代码正确 A: for i in range (300,401):if i%3==0 continue print i B: for i in range (299,401):print i, if i%3==0 continue print i C: for i in range (300,400):if i%3==0 continue print i D: for i in range (301,401): if i%3==0 continue print i
- 编写一段代码使用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(2): print(i)for i in range(4,6): print(i)
- 阅读下面Python代码,选择正确输出结果:() for i in range(5): if i == 3: continue print(i,end=" ") continue print(i,end=" ") A: 0 1 2 3 4 5 B: 0 1 2 3 4 C: 2000 1 2 D: 0 1 2 4
- 以下程序的输出结果是? y = 0 for i in range(0, 10, 2): y += i print (y)