Division Operators in Python:

Let’s look at the statement given below in Python 2.7 for Data Science.

Division Operators in Python for Data Science - PST Analytics

The first result is ok, but the second one can be confusing to people who already have done C++ or Java. We should remember that in Python 2.7, “/” operator acts as a floor division for integer arguments. But if we want to obtain a float value, then one of the arguments should be a float.

Division Operators in Python for Data Science - PST Analytics

“//” is the real floor division operator. Whether you enter an integer or a floating-point as an argument it returns floor value.

Python 3:

In Python 3 “/” operator returns floats in case of both integer and float as arguments.

Division Operators in Python for Data Science - PST Analytics

If you want to learn more about division operator in python for data science then you can check this and this.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.