编写一段代码使用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)
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(4): if i%2==0: print(i) break print(i) 结果是
- 执行以下代码,依次输出哪些数字?for i in range(2): print(i)for i in range(4,6): print(i)
- 下列程序段的输出结果是___________。for i in range(5):if i%2 == 0:print(i)else:print(i)
- 下面代码中输出结果为0、1、2三个数字的有(_____)。 A: for i in range(3): print(i) B: i=1 while i<3: print(i) i+=1 C: i=3 while i>1: i=i-1 print(3-i) D: for i in range(3,0,-1): print(3-i)
- 智慧职教: 以下代码的输出结果为: for i in range(10): if i%2 != 0: continue print(i)