当前位置:网站首页>Example 045: Summation

Example 045: Summation

2022-08-10 03:31:00 lazily

Title: Count the sum of 1 to 100.

Program Analysis:None

I. Code

# Method 1res = 0for i in range(1, 101):res += iprint(res)# Method Twoprint(sum(range(1, 101)))

Second, results

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓LazyXiaofan sincerely invites you to click below to learn and discuss together↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

原网站

版权声明
本文为[lazily]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208100201343471.html