# Python program to add two numbers

## Introduction:

In this article, I am going to explain a Python program to add two numbers. If you are trying to use python operators then the Python program to add two numbers is a good beginning.

There are several types of operators available in python but if you want to learn python arithmetic operators then Python program to add two numbers is a good choice.

## Algorithm:

Here, I am going to explain the logic of program with the help of a simple algorithm Here, I am going to explain the logic of program with the help of a simple algorithm

Algorithm is a set of finite steps which when carried out for given inputs, produces some output in a  fixed duration of time.

### Algorithm to add two numbers

Step 1 Take user input a and b

Step 2 Add these inputs a and b. and assign as follows

C =a+b

Step 3 print the result

## Python program to add two numbers

a=int(input(“Enter a number”))

b=int(input(“Enter a number”))

c=a+b

print(“The result is “,c)

Enter a number 5

Enter a number 5

### Output

The result is  10

### Explanation

I am using input() function to accept values for a and b.

By default, the data type of user input is string that’s why I am using int() function to convert into integer.

## Python program to add two numbers

a=float(input(“Enter a number”))
b=float(input(“Enter a number”))
c=a+b
print(“Result is “,c)

### Input

Enter a number1.2
Enter a number1.2

Result is 2.4

### Explanation

I am using input() function to accept values for a and b.

By default, the data type of user input is string that’s why I am using float() function to convert into float.

## Conclusion

Python is a dynamic type of language. It means that there is no need to declare the variable in advance that’s why I am using variables a,b, and c directly without the declaration.