+ 1
why 2**10 is 1024 not 1024.0
python float
10 Respuestas
+ 6
or you can type .. 2.0**10 the output would then be 1024.0 ... i think so :p
+ 5
Because You are not operating with float numbers
+ 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
+ 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
+ 1
ok.thnx for the help.😊
0
do i need to specify float type before to get float characters
0
yes, you do
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
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
0
doesn't matter, still the same answer