Can anyone explain this | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone explain this

#py -15//10 #output : -2.0

6th Jan 2021, 4:31 PM
Surkhab Khan
Surkhab Khan - avatar
2 Answers
+ 3
// truncates fractional parts, which means rounding towards negative infinity. This direction of rounding is the same for positive and negative numbers, so -1.5 is rounded to -2. Side note: the output is -2, not -2.0, since // yields an integer
6th Jan 2021, 5:43 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 2
10 ---> 0 {the first time} 0 ---> -10 {the second time} For your purpose, use -(15//10).
6th Jan 2021, 4:41 PM
Calvin Thomas
Calvin Thomas - avatar