Python Program to find the sum of two floating numbers

April 14, 2022, Learn eTutorial

How to find the sum of float point numbers in python?

The sum is one of the basic mathematical operations which we do in all our daily life. Addition, Subtraction, Multiplication, and Division are the basic operations in mathematics. So in this simple python program, we are doing the sum of two floating-point numbers.

Float numbers are double-precision numbers. For example, 73.45 it is a float point number and 12.34 is another floating-point number. We have to calculate the sum of these two numbers. '73.45 + 12.34 = 85.79'.

In this Python program, we are accepting two values from the user and convert that values into the integer using an 'int' function. Use a variable sum for calculating the sum of these two float point numbers. Finally, display the sum using the print function in Python language.


STEP 1: Accept the user values using the input function in the python programming language. Convert that string value to float using float datatype and save the number in a variable.

STEP 2: Add the numbers that the user input using the sum '+' operator in python. Please note to use the float data type while add and save the result in another variable.

STEP 3: Display the result using a print function.

Python Source Code

                                          num1 = float(input("Enter the first number: "))

num2 = float(input("Enter the second number: ")) #accpeting and converting the string to float and save in vaiable

sum = num1 + num2  # doing the addition using '+' operator

print("The sum is: ", sum)   # display the result of the sum 


Enter the first number: 80.60

Enter the second number: 20.40

The sum is: 101.00