题目
ACCN-3290-02Sp25 Week 1 Quiz
单项选择题
Which of the following code snippets correctly prints the numbers from 1 to 10, except for those divisible by 3?
选项
A.for i in range(1, 11):
if i % 3 != 0:
print(i)
i += 1
B.for i in range(1, 11):
if i % 3 == 0:
break
else:
print(i)
C.for i in range(1, 11):
if i % 3 == 0:
print(i)
D.for i in range(1, 11):
if i % 3 != 0:
print(i)
查看解析
标准答案
Please login to view
思路分析
We’re evaluating code snippets to print numbers 1 through 10 while skipping those divisible by 3.
Option 1:
for i in range(1, 11):
if i % 3 != 0:
print(i)
This checks each i from 1 to 10 and prints i only when i is not a multiple of 3. Therefore it prints 1......Login to view full explanation登录即可查看完整答案
我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。
类似问题
Consider the code below. What value will be displayed? int total = 0; for (int i = 1; i <= 4; i++) { if (i % 2 == 0) total += i; } MessageBox.Show(total.ToString());
Which of the following is the proper syntax to loop through every other value of a row vector x?
Given a list values that contains the first ten prime numbers, which statement does NOT print each element in the list?
Which of the following for loops will run the loop body 5 times?
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!