+ 35
Why is 8/2=4.0 and not 4?
75 odpowiedzi
+ 190
In Python by default take float data type
So any division calculations it will give us floating value
Suppose that 24/12 = 2.0 not 2
But 24 // 12 = 2 not 2.0
Try to understand difference
/ - is division it will give floating value
// - is floor division it will give integer value
+ 19
Division always give floating point number. That's why 8/2 = 4.0
+ 12
Because a / operation returns a float. If you want to do an euclidian division, use //.
+ 6
in python default data type is float if you use 2/2 gives float data type as 1.0 or if you use 2//2 gives you 1 which is an integer.
+ 5
thanks for this que.
+ 4
When it comes to python, you always get the answer ( if you not change the data type, you able to get the result) in float data type
+ 2
Will division of floating numbers using // also give whole numbers?
+ 2
@Pratik .... Yeah exactly result of division is always be be a float number. Like If you divide 6/2 it's answer will be 3.0 not 3
+ 2
division(/) sets float data type.
+ 2
inpython values are taken by default in float
+ 2
python always gives access result of division as a floating number. but if you want to get a whole number by a division you have to use floor division .
like this 8//4
+ 2
When ever you divide using a forward slash it results in a float. A float is a decimal.
+ 1
that's because normally when a number is divided in programming languages like python and java and some other using / sign we get output is float data type..!
+ 1
This is one of the new features of python3 vs. python2
in python2 you can start your programme with "from __future__ import division" to reproduce python3 division
+ 1
division with / in Python always results in a float value
+ 1
python silently convert integer into float
+ 1
en python toujours la division donne un float
+ 1
8/2=4.0 and 8//2=4 !!!
+ 1
but,python is a interpreted language
so,it is convert all number in floating numbers.
+ 1
Thank you for this post :)