+ 1
Some one tell me, why ? This.
10 Respostas
+ 7
Hi Amit!
'//' operator is called floor division.
It gives floor of an integer as it name suggests.
The floor of any integer gives the greatest integer less than or equal to that particular integer.
In this case, the floor of (-5//2) -2.5 gives -3 which is the greatest integer less than or equal to -2.5.
The floor result can't be -2 since -2 is greater than -2.5
+ 1
Eashan Morajkar
But answer is -3.
+ 1
Like 2.5 to 2 and -2.5 to -3, one integer back
+ 1
Python Learner
Thanks hooo. đ
+ 1
Eashan Morajkar JUMP_LINK__&&__Python__&&__JUMP_LINK Learner Amit Ranjan Sahoo The answer is -3 please read carefully to understand. When u say 5//2 the answer is 2 (I believe you know this sign now // [floor division] because 5 Ă· 2 = 2.5, and Python was designed to find the least closest integer(int) to the float answer... so 2.5 has to close integers which is 2 and 3. And 2 < 3 therefore the answer is 2.
But when u say -5//2, the solution goes like this; -5Ă·2= -2.5 and -2.5 has two close integers -2 and -3 and I believe you ought to know that -3 is smaller than -2(from number lines or directed Numbers *if you were thought that in school*) so the answer is -3
I hope you understand this
+ 1
Amit Ranjan Sahoo Lolđđ.. thanks man
0
It's -2 because "//" returns integer part of division which is -2.5 and the integer part is -2, so -2 us the answer
0
Ejeh Joseph
bro i knew the number series and its functionsđ
, i was condused in the function of //. btw thanks for a long explanation đ
- 2
In minus it's showing-3 but in 5 it shows 2
- 3
I think it rounds it up to the last integer