Adding Numbers | Python

Python Program to add two Numbers

# Python Program for adding Numbers
num1 = 19.2
num2 = 12.1

# Adding Two Numbers
sum = num1 + num2

# Printing Sum of numbers
print('Sum of two numbers {0} and {1} is {2}'.format(num1, num2, sum))


Sum of two numbers 19.2 and 12.1 is 31.299999999999997

Adding Two Numbers Inputed By User

# Python Program for adding Numbers taking input from User
num1 = input("Enter first number => ")
num2 = input("Enter second number => ")

# Adding Two Numbers inputted by User
sum = float(num1) + float(num2)

print('Sum of two numbers {0} and {1} is {2}'.format(num1, num2, sum))


Enter first number => 10
Enter second number => 2
Sum of two numbers 10 and 2 is 12.0

In the above Python, float(num1) and float(num2) is used as input() function always take in value as a String, but for adding Number is required.

More About Python


Hi, there I'm founder of ComputerScienceHub(Started this to bring useful Computer Science information just at one place). Personally I've been doing JavaScript, Python development since 2015(Been long) - Worked upon couple of Web Development Projects, Did some Data Science stuff using Python. Nowadays primarily I work as Freelance JavaScript Developer(Web Developer) and on side-by-side managing team of Computer Science specialists at

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts