Some one tell me, why ? This. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
5th Aug 2021, 4:13 AM
UnTentetive
10 Answers
+ 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
5th Aug 2021, 4:56 AM
Python Learner
Python Learner - avatar
+ 1
Eashan Morajkar But answer is -3.
5th Aug 2021, 4:19 AM
UnTentetive
+ 1
Like 2.5 to 2 and -2.5 to -3, one integer back
5th Aug 2021, 4:21 AM
Eashan Morajkar
Eashan Morajkar - avatar
+ 1
Python Learner Thanks hooo. 😄
5th Aug 2021, 4:59 AM
UnTentetive
+ 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
6th Aug 2021, 11:25 AM
Ejeh Joseph
Ejeh Joseph - avatar
+ 1
Amit Ranjan Sahoo Lol😂😂.. thanks man
7th Aug 2021, 10:18 AM
Ejeh Joseph
Ejeh Joseph - avatar
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
5th Aug 2021, 4:16 AM
Eashan Morajkar
Eashan Morajkar - avatar
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 😊
7th Aug 2021, 2:49 AM
UnTentetive
- 2
In minus it's showing-3 but in 5 it shows 2
5th Aug 2021, 4:20 AM
Eashan Morajkar
Eashan Morajkar - avatar
- 3
I think it rounds it up to the last integer
5th Aug 2021, 4:21 AM
Eashan Morajkar
Eashan Morajkar - avatar