Today, We want to share with you **sum() in python**.In this post we will show you **addition program in python using functions**, hear for *Python Program to Add Two Numbers* we will give you demo and example for implement.In this post, we will learn about *Shell Script to Add Two Numbers using ommand line arguments* with an example.

## How To Do Math in Python 3 with Operators?

**write a program to add two numbers in python?**

**Example 1: **

This program adds two numbers

level1 = 1.5 level2 = 6.3 # Add two numbers sum = level1 + level2 # Display the sum print('The sum of {0} and {1} is {2}'.format(level1, level2, sum))

### sum of n numbers in python using for loop

**Example 2: **

Python Program to find Sum of N Natural Numbers

totalno = int(input("Please Enter any Number: ")) total = 0 for value in range(1, totalno + 1): total = total + value print("The Sum of Natural Numbers from 1 to {0} = {1}".format(totalno, total))

### python sum(range of numbers)

**Example 3: **

Python Program to Calculate Sum and Average of first n natural numbers

n = 10 sum = 0 for level in range(0, n+1, 1): sum = sum+level print("SUM of first ", n, "totalnos is: ", sum )

**Python Program to calculate average**

print ("calculate an average of first n natural totalnos") n = 10 average = 0 sum = 0 for level in range(0,n+1,1): sum = sum+level; average = sum / n print("Average of first ", n, "natural totalno is: ", average)

Calculate the sum and average of first n natural totalnos using formula

n = 10 sum = n * (n+1) / 2 average = ( n * (n+1) / 2) / n print("Sum of fthe irst ", n, "natural totalnos using formula is: ", sum ) print("Average of the first ", n, "natural totalnos using formula is: ", average )

Calculate the sum and average of a given list in Python

sum = 0 list = [11,22,33,44,55,66,77] for level in list: sum = sum +level average = sum / len(list) print ("sum of list element is : ", sum) print ("Average of list element is ", average )

Python while loop to calculate sum and average

n = 20 total_numbers = n sum=0 while (n >= 0): sum += n n-=1 print ("sum using while loop ", sum) average = sum / total_numbers print("Average using a while loop ", average)

I hope you get an idea about **How to compute the sum of a list in python?**.

I would like to have feedback on my infinityknow.com blog.

Your valuable feedback, question, or comments about this article are always welcome.

If you enjoyed and liked this post, don’t forget to share.