第25412题 单选题
关于Python实现1-N奇数求和代码的描述,错误的是?

下面的Python代码用于求1-N之间所有奇数之和,其中N为正整数,如果N为奇数求和时包括N。

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