+ 1

why 2**10 is 1024 not 1024.0

python float

28th Oct 2016, 4:09 PM
Sangharsh Seth
Sangharsh Seth - avatar
10 Respuestas
+ 6
or you can type .. 2.0**10 the output would then be 1024.0 ... i think so :p
28th Oct 2016, 5:55 PM
Youness Ibn Salah
Youness Ibn Salah - avatar
+ 5
Because You are not operating with float numbers
28th Oct 2016, 4:52 PM
Iago Muñoz Varela
Iago Muñoz Varela - avatar
+ 3
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
28th Oct 2016, 6:05 PM
Ugra Narasimha
Ugra Narasimha - avatar
+ 2
Let us look at mathematical rule of the expression. The operation 2**10 or written in Math Form 2^10 is exponential expression consisting of two terms (The base Number in this case is 2 and the exponent number 10). The base number is an integer number which is 2 and also our exponent number is 10 which is again an integer. So the outcome of an exponent operation on two pure integer numbers will always be an integer. That is why 2**10 = 1024 But 2**10.0 =1024.0 I hope that makes sense
30th Oct 2016, 5:30 AM
Mubarig Cisman
Mubarig Cisman - avatar
+ 1
ok.thnx for the help.😊
28th Oct 2016, 5:17 PM
Sangharsh Seth
Sangharsh Seth - avatar
0
do i need to specify float type before to get float characters
28th Oct 2016, 4:55 PM
Sangharsh Seth
Sangharsh Seth - avatar
0
yes, you do
28th Oct 2016, 4:57 PM
Iago Muñoz Varela
Iago Muñoz Varela - avatar
0
or You can simply do this: (2**10)/1 whenever you make a division the program will automatically set that result as a floatable even if its .0
28th Oct 2016, 5:00 PM
Iago Muñoz Varela
Iago Muñoz Varela - avatar
0
n 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
29th Oct 2016, 3:25 AM
Ugra Narasimha
Ugra Narasimha - avatar
0
doesn't matter, still the same answer
24th Nov 2016, 10:35 PM
Eddy Tshibasu
Eddy Tshibasu - avatar