How to add two numbers in python ?

Written by

Himani Kohli

Program to add two numbers in Python

In this python program, we will be learning to add two numbers using Python.

To better understand the concept we have an example:

Input:

a=5,

b=6

Output:

sum=11

Here, input a and b is taken by the user and then we get the resulting sum as output.

Algorithm:

1) Input the numbers from the user.

2) Addition of numbers is stored into a variable “sum”.

3) Print the sum.

Code:

a=int(input(“enter the first number:”)) //input first number

b=int(input(“enter the second number:”)) //input second number

sum=a+b //addition of two numbers

print(“sum:”, sum) //the required sum is printed

Output:

enter the first number: 2

enter the second number: 4

sum: 6

How to add two numbers in python ?