Python Example Program to Add Two Numbers ( User Input )

Learn to write a Simple Python Program to Add Two Numbers

In this program we ask the user to enter two numbers and then we add them and display the result.

Source Code for add two numbers.py

 1 # Read the First Number and Store it in a Variable
 2 num1 = int(input("Enter Number 1 : "))
 3 
 4 #Read the Second Number and Store it in another Variable
 5 num2 = int(input("Enter Number 2 :"))
 6 
 7 #Add the 2 Numbers and store the result in another variable
 8 result = num1 + num2
 9 
10 #Display the result
11 print("{0} + {1} = {2}".format(num1,num2,result))

Watch this video to learn how this works