0

How can we get a float when we divide two integers? For this to happen either one of it should be float.

5th Aug 2016, 4:19 AM
Rushikesh Ganne
4 Antworten
+ 6
In python 3, the / operator is for float division. So you will get a float result regardless of if the operands are float or not. For integer division, use //. E.g 2/1 outputs 2.0 2//1 outputs 2
5th Aug 2016, 9:11 AM
Gershon Fosu
Gershon Fosu - avatar
+ 1
although 2/1 would output 2.0, not 1
7th Aug 2016, 3:51 AM
Jonathan Dennerly
0
Thanks.
5th Aug 2016, 10:41 AM
Rushikesh Ganne
0
Haha yeah omg i better change that
7th Aug 2016, 4:29 AM
Gershon Fosu
Gershon Fosu - avatar