Select Page

# Program to add two numbers in Python

by | Dec 22, 2020 | Python Programs

Home » Python » Python Programs » Program to add two numbers in Python

## Introduction

In this section of python programming, we will learn the addition of two numbers by using arithmetic operator +. Let us now look into the python code.

## Program

Program 1: Adding two given numbers ```num1 = 9
num2 = 2
sum_res = num1 + num2
#Display result
print("The sum of number {0} and {1} is {2}".format(num1, num2, sum_res))
```

OUTPUT: Program 2: Adding two numbers by taking user input ```num1 = input("Please enter the first number: ")
num2 = input("Please enter the second number: ")
sum_res = float(num1) + float(num2)
#Display result
print("The sum of number {0} and {1} is {2}".format(num1, num2, sum_res))
```

OUTPUT ## Explanation

In the above programs we are adding two numbers num1 and num2 and the sum is stored in third variable sum_res. In Program 2, we are taking the input numbers from the user through input() function and the resultant addition is stored in variable sum_res. The output is displayed by print() function.

## Author

• A Full Stack Developer with 10+ years of experience in technical content creation.

• 