Python Program to Add Two Numbers
Write a Python program take input of two numbers and calculate sum of two numbers.
This program will prompt user to input two numbers on standard input. Then calculate sum of two numbers a print sum of both values on standards output.
The following Python program uses input() function to take input of 2 number from user. Calculate the sum and use print() function to print result.
#A sample Python program to input two number
#And calculate sum of both numbers
#Take input of two numbers from user
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
sum = a + b
print("Sum of input numbers is:", sum)
Execute this program:
Enter first number: 10 Enter second number: 5 Sum of input numbers is: 15