# Python program to add two number

Python program to add two number

This program will add the two numbers and display their sum on the screen.

Example:

```Input: Number1 = 20        Number2 = 30
Output: Sum = 20 + 30         = 50```
``` #Program to calculate the sum of two number
#Take two number from user
number1 = int(input("Enter the first number:"))
number2 = int(input("Enter the second number:"))
# perform calculation and store in a variable sum
sum = number1 + number2
#Print the result
print('sum of {0} and {1} is {2}' .format(number1, number2, sum)) ```

Output

Here is the result:

Explanation: In this program, a user asks to enter two numbers that will be stored in two different variables named number1 and number2, respectively. A variable sum is used to hold the addition of these two numbers. Finally, the sum of two numbers will be displayed on the screen using the print function.

Using Function

The following is a source code to get a sum of two numbers using functions:

``` #Program to calculate sum of two number using function
# create function to return sum
def calc_sum(number1, number2):
sum = number1 + number2
return sum
#Take two number from user
number1 = int(input("Enter first number:"))
number2 = int(input("Enter second number:"))
#Print the result
print('sum of {0} and {1} is {2}' .format(number1, number2, calc_sum(number1, number2))) ```

Output

Here is the result:

CASE 1:

CASE 2:

Explanation: In this program, we have created a function and have passed two arguments, number1 and number2. This function will return the value of the sum. A user has asked to take two integer numbers as an input and store them in two separate variables. We need to call the function to print the sum of two given numbers.