Home > Backend Development > Python Tutorial > How to calculate the sum from 1 to 100 using python?

How to calculate the sum from 1 to 100 using python?

coldplay.xixi
Release: 2020-06-09 15:41:17
Original
30265 people have browsed it

How to calculate the sum from 1 to 100 using python?

How to calculate the sum from 1 to 100 using python?

The code for python to calculate the sum of 1 to 100 is as follows:

sum = 0
for i in range(1,101):
    sum = sum + i
print(sum)
Copy after login

Output result: 5050

Recommended tutorial: " Pyrhon video tutorial

The above is the detailed content of How to calculate the sum from 1 to 100 using python?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template