# Python Program to Add Two Numbers

Python program to add two numbers; Through this tutorial, you will learn how to add two numbers using + operator in python program.

# Python Program to Add Two Numbers

See the following python programs to add or sum of two numbers in python; as shown below:

• 1: Simple Python Program to Add Two Numbers
• 2: Python Program to Add Two Numbers with User Input
• 3: Python Program to Add Two Numbers Using Functions

### 1: Simple Python Program to Add Two Numbers

• Define two variable with value in program.
• Calculate the sum of two numbers and store it in variable.
• Print sum of two number
```a = 10
b = 20

sum = a + b

print("sum:", sum)
```

Output

sum: 30

### 2: Python Program to Add Two Numbers with User Input

• Take input two numbers from user in program.
• Calculate the sum of two numbers and store it in variable.
• Print sum of two number
```a = int(input("enter first number: "))
b = int(input("enter second number: "))

sum = a + b

print("sum:", sum)
```

Output

enter first number:10
enter second number:20
sum: 30

### 3: Python Program to Add Two Numbers Using Functions

• Create function, which is used to calculate the sum of two numbers and store it in variable.
• Take input two numbers from user in program.
• Print sum of two number
```# Program to illustrate
# the use of user-defined functions

sum = x + y
return sum

num1 = 15
num2 = 20

```

Output

sum: 35