+ 2
So then why don't we add a float number? 20 // 6 is 3, but why isn't it defined as 3.33 or something alone those lines?
2 Réponses
+ 6
Python has two division operators: '/' is used for true division and '//' is used for floor division.
The true division operator returns a float, and the floor division operator returns an int.
So if you want to get 3.333 as result you probably what the true division operator.
But if you want the result without the remainder use the floor division.
+ 2
// is dividend operator.
For instance, 20 divided by 6 gives 3 (2 remainder). So 20//6 = 3.
Also you might confuse that with division operator (/), which gives your example 3.33 as the result