# Python Program to Add Two Numbers

Basic Python Program to Add Two Numbers

In this article, I will take you through a basic Python program to add two numbers. If you are a beginner in Python or any other programming language then generally this will be your second program after printing the “Hello, World”.

## Python Program to Add Two Numbers:

To write a python program to add two variables is same as doing the addition of two integers mathematically. First, we need to declare two variables by assigning their values, and then we need to assign the sum of those two variables in a new variable.

Then we can simply print the output by printing the variable that is the sum of two variables. Let’s see how to do this with Python:

```.wp-block-code {
border: 0;
}

.wp-block-code > div {
overflow: auto;
}

.hljs {
box-sizing: border-box;
}

.hljs.shcb-code-table {
display: table;
width: 100%;
}

.hljs.shcb-code-table > .shcb-loc {
color: inherit;
display: table-row;
width: 100%;
}

.hljs.shcb-code-table .shcb-loc > span {
display: table-cell;
}

.wp-block-code code.hljs:not(.shcb-wrap-lines) {
white-space: pre;
}

.wp-block-code code.hljs.shcb-wrap-lines {
white-space: pre-wrap;
}

.hljs.shcb-line-numbers {
border-spacing: 0;
counter-reset: line;
}

.hljs.shcb-line-numbers > .shcb-loc {
counter-increment: line;
}

.hljs.shcb-line-numbers .shcb-loc > span {
}

.hljs.shcb-line-numbers .shcb-loc::before {
border-right: 1px solid #ddd;
content: counter(line);
display: table-cell;
text-align: right;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
width: 1%;
}
```num1 = 5
num2 = 7
sum = num1 + num2
print(f"Addition of{num1, num2} is :{sum}")``````

Addition of(5, 7) is :12

Now as we can see the output, it gives the sum of two numbers. Let’s see how we can add two numbers by taking user input. So now I will write a python program to add two numbers by taking a user input. Let’s see how we can do this:

``````num1 = input("Enter Number 1 :")
num2 = input("Enter Number 2 :")
sum = int(num1) + int(num2)
print(sum)``````

Enter Number 1 :10
Enter Number 2 :20
30

I hope you liked this article on how to write a Python program for the addition of two variables. Feel free to ask your valuable questions in the comments section below.