How to add two float numbers in Python

Let's see how we can add two float numbers in Python using a program.

# Code2care Python Programming:
# Add two float numbers
# in Python

float_number_1 = float(10.97)
float_number_2 = float(11.13)

sum_of_two_float_numbers = float(float_number_1 + float_number_2)

print('Sum: {0} + {1} = {2}'.format(float_number_1, float_number_2, sum_of_two_float_numbers))

PyCharm Output:
/Users/code2care/.local/share/virtualenvs/examples-E9HN9Crc/bin/Python /Users/code2care/PycharmProjects/examples/
Sum: 10.97 + 11.13 = 22.1

Process finished with exit code 0

Python Program add two Floats
Python Program add two Floats
  1. Create a variable float_number_1 that holds the first floating number,
  2. Create a variable float_number_2 that holds the second floating number,
  3. Now create a variable sum_of_two_float_numbers that holds the sum of the two numbers.
  4. Make use of the + Operator to add two floats,
  5. Print the sum in console using print method.

Have Questions? Post them here!

Recent Posts:

Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.