Let us now discuss how the arithmetic Operation Division is performed in python 2 was John buses Python
3 classic division the classic division is the default division operator behavior in python 2 wasn't
as well as in today's programming languages such as Java and C C++ so when presented with integers opera
and classic division truncate D decimal places and returned an integer when given a pair of floating
point operations it returns actual floating point question.
So in python 2 was shown in python 2 was shown when you divide 5 by 2 which are both integers.
The result would be 2 but if you divide 5 dot all which is a floating point number that 2 The result
would be too darn fine.
So here to have opened the Jupiter notebook and I am now working on the Python 2 was in the notebook
document is currently connected to the kernel Python 2.
So let us divide 5 by 2 and execute the same so as you can see classic division has truncated the decimal
place.
Returning an integer.
Now let us divide 5 dot or by 2.
And in this case the actual floating point question has been written next true division true division
is where the result is always the ideal floating point question regardless of the operant type.
And this is the D5 division operation in any python 3 releases.
In true division when you do Y 5 by 2 The result would be to dot 5 when you divide the floating by number
5 dot or by the integer 2.
The result would be 2.5 regardless of the operant type whether it is an integer or a floating point
number.
The result is always deal floating point question.
OK in order to demonstrate true division I have open another new notebook and this time the kernel is
Python 3 so let's divide 5 the integer 5 by 2 in Python 3.
The answer is 2.5 if we go to a bed or floating point values.
The answer or the quotient is always a floating by number using flawed division began get an integer
present that is by discarding a need fractional reserve and this can be done using the new division
operator which always truncate diffraction and drowns it to the next smallest whole number towards the
left on the number line regardless of the opera and numeric types.
So if you divide one by two using the flawed division the question would be zero because flawed division
truncate the fractional part and it round the question to the next hole numbered toward the left of
the number line.
So instead of zero dark 5 the question would be 0 next.
If we divide the floating by number one dot all using float division to dot or the result would be zero
dark zero so it returns a floor next.
If we do Y minus one by two using flawed division the answer would be minus 1.
The output in this case instead of minus zero point five it would be truncated to minus one because
negatives move left on the number line.
So let us check the flow division in the Python 3 notebook.
So one door or divided by two using flawed division would give me zero dot zero whereas if we give a
minus a negative number so minus 1.
This should be minus 1.
We have just discussed that in Python 2 the D5 division is the classic or the old division and the flawed
division is only available in Python 3 and if you want to use the flawed division functionality in Python
2.
In that case you need to use the future module.
The future module allows us to import Python 3 functionality in python 2 the floor division functionality
is available in Python 3 version but not in Python 2.
So in order to allow us to use the functionality that is mandatory in future Python versions such as
Python 3 we can use the statement we can use the future module which allows us to import Python 3 functionality
in Python 2.
So in here is the statement from underscored underscored future underscore underscore.
Import division.
So from the future module we are importing the division functionality so let's execute this code.
Now if you perform flawed division in python 2 The question would be truncated when you divide one dot
or by two using flawed division instead of returning 0 ORDER BY THE quotient would be truncated to zero
dot zero which is a floating point number.
Say for example if you divide a negative number minus one by two using flawed division the result would
be minus 1 instead of minus zero dot fly.