What is the function of (//)operator?my statement (true/false) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the function of (//)operator?my statement (true/false)

20//6 =3. Because 6 can only go 3 times in 20 !so // operator checks how many times a number goes into another number

12th Aug 2020, 7:05 PM
DeadEye UNT
DeadEye UNT - avatar
10 Answers
0
No i need help understanding the operators
12th Aug 2020, 7:11 PM
DeadEye UNT
DeadEye UNT - avatar
0
the answer is simply yes 👍
12th Aug 2020, 7:12 PM
Oma Falk
Oma Falk - avatar
0
I thank you
12th Aug 2020, 7:15 PM
DeadEye UNT
DeadEye UNT - avatar
0
I understand now thank you for explaining it to me
12th Aug 2020, 8:30 PM
DeadEye UNT
DeadEye UNT - avatar
0
It's false, because there is an exception when either of the operands were negative: -20//6=-4 I don't want to explain why it's giving that result.
12th Aug 2020, 9:31 PM
Seb TheS
Seb TheS - avatar
0
??? Where did you get the -20//6?
12th Aug 2020, 9:37 PM
DeadEye UNT
DeadEye UNT - avatar
0
DeadEye UNT On this Q&A, it has been asked many times why negative floordivisions give weird results.
12th Aug 2020, 9:46 PM
Seb TheS
Seb TheS - avatar
0
But that's because floor is a concept of converting a decimal number into an integer. Let's pick a random decimal number: 8.4 If you want to convert it to an integer, you would have to choose between 8 and 9. floor operator always chooses the smaller integer and that's where the floordivision gets its name. -20/6 ~ -3.33 -3.33 is located between -4 and -3, thus floor division would choose -4.
12th Aug 2020, 10:01 PM
Seb TheS
Seb TheS - avatar
0
I see i understand why it does that nnow
12th Aug 2020, 11:07 PM
DeadEye UNT
DeadEye UNT - avatar
0
This is because it always chooses the next smaller number to the result, which, in this case, would be -4...
14th Aug 2020, 6:18 AM
Julian