第25548题 单选题
针对该数列求和代码,选出正确的说法

Python编程求数列 -1+2+3-4+5+6-7+8+9-10+11+12-13+……之值。如输入4,则计算1到4(包含1和4)之间的值,规律如数列所示。下面说法正确的是()。

N = int(input("请输入正整数: "))
tnt = 0
for i in range(1, N + 1):
    if i % 3 == 1:
        tnt += -i
    else:
        tnt += i
print(tnt)
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析