下列选项中,能找出三位数中,所有个位数字是9并且是3的倍数的数的代码是( )。
A: for i in range(100,1000): if i%10=9 and i%3=0: print(i,end=' ')
B: for i in range(100,1000): if i//10==9 and i//3==0: print(i,end=' ')
C: for i in range(100,1000): if i%10==9 and i%3==0: print(i,end=' ')
D: for i in range(100,1000): if i%10==9 and i%3==0: print(i,end=' ')
A: for i in range(100,1000): if i%10=9 and i%3=0: print(i,end=' ')
B: for i in range(100,1000): if i//10==9 and i//3==0: print(i,end=' ')
C: for i in range(100,1000): if i%10==9 and i%3==0: print(i,end=' ')
D: for i in range(100,1000): if i%10==9 and i%3==0: print(i,end=' ')
举一反三
- 一个三位数,若它的每个数字(即百位、十位、个位)的立方和等于该数,则该数称为水仙花数,显示水仙花数的程序是: A: for i in range(1,1000): x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i) B: for i in range(100,101): x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i) C: i=100 while i<=999: x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: print("水仙花数为:",i) i++ D: for i in range(100,1000): x=i//100 y = i//10%10 z=i%10 if x**3+y**3+z**3 == i: 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
- 下面的循环体执行的次数与其它不同的是( )。 A: for i in range(100): print(i) B: i = 0 while(i <= 1000): print(i) i = i+1 C: i =100 while(i>0): print(i) i=i-1 D: for i in range(100,0,-1): print(i)
- 下面的循环体执行的次数与其它不同的是________。 A: i=0 while(i<=1000): print(i) i=i+1 B: for i in range(100): print(i) C: for i in range(100,0,-1): print(i) D: i=100 while(i>0): print(i) i=i-1
- 编写一段代码使用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)