- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to Find the Sum of Natural Numbers using Python?

You can use while loop to successively increment value of a variable i by one and adding it cumulatively.

s,i=0,0 n=10 while i<n: i=i+1 s=s+i print ("sum of first 10 natural numbers",s)

For loop is also used to loop over a range of natural numbers and add them cumulatively.

s=0 for i in range(11): s=s+i print ("sum of first 10 natural numbers",s)

Lastly using the built in function sum() also gives sum of a range of numbers

s=sum(range(11)) print ("sum of first 10 natural numbers",s)

- Related Questions & Answers
- How to Find Sum of Natural Numbers Using Recursion in Python?
- Java Program to Find the Sum of Natural Numbers using Recursion
- C++ program to Find Sum of Natural Numbers using Recursion
- Java program to find the sum of n natural numbers
- 8085 program to find the sum of first n natural numbers
- PHP program to find the sum of cubes of the first n natural numbers
- Java Program to Calculate the Sum of Natural Numbers
- Program to find sum of first n natural numbers in C++
- PHP program to find the sum of cubes of natural numbers that are odd
- PHP program to find the sum of the 5th powers of first n natural numbers
- C++ Program to Calculate Sum of Natural Numbers
- Sum of sum of first n natural numbers in C++
- Python Program for cube sum of first n natural numbers
- Python Program for Sum of squares of first n natural numbers
- How to find the Sum of two Binary Numbers using C#?

Advertisements