Python Floating Point Numbers


One important thing to know when you are programming in Python, is how Python deals with floating point numbers. I created a simple and small project in Jupyter Notebook to illustrate this. I called it Floating-Point Numbers. Here is a screenshot.

This could cause some problems is you are running if statements or conditions against this value. If you were to then have a step in your code that identifies values ≤ 5.3, this would not be included in the result, when it should be.

The key takeaway from this is that whenever you perform a calculation to compute a number that is then used to make an important decision or filtration, round the number.

The number of decimal places you specify will depend on how precise you need to be.

Leave a Reply