测试积点老人 发表于 2024-10-31 09:36:47

用while循环计算 1 到 100 的整数和?

回复可见
**** Hidden Message *****

你好浮戈 发表于 2024-11-1 09:24:19

sum_of_numbers = 0
counter = 1

while counter <= 100:
    sum_of_numbers += counter
    counter += 1

print(sum_of_numbers)

kallinr 发表于 2024-11-1 09:31:38


sum_of_numbers = 0
counter = 1

while counter <= 100:
    sum_of_numbers += counter
    counter += 1

print(sum_of_numbers)

oliver.tang 发表于 2024-11-1 10:00:55

while

海海豚 发表于 2024-11-1 10:05:44

sum_of_numbers = 0
counter = 1
while counter <= 100:
    sum_of_numbers += counter
    counter += 1

print(sum_of_numbers)

litingting0214 发表于 2024-11-1 10:27:51

sum_of_numbers = 0
counter = 1
while counter <= 100:
    sum_of_numbers += counter
    counter += 1

print(sum_of_numbers)

jingzizx 发表于 2024-11-1 13:06:24

while ++
页: [1]
查看完整版本: 用while循环计算 1 到 100 的整数和?