+ 1
I don't understand the '//' simbol
for example 5 // 2 = ?? 300 // 10 = ??
4 Respuestas
+ 9
it will take the integer part of the division
7/2 will be 3.5
but
7//2 will give us only the integer 3
+ 9
In Python this sign // is called the floor division and this % is the modulo operator
The floor division // operator will only provide your answer without remainder
The modulo % operator will only give you the remainder as you answer.
Just in the case of this
>>> 20 // 6 meaning how many times do 6 goes in 20. 6 will go in 20 3times remainder 2 but don't forget your answer will only be 3 because of this sign //
And as for this
>>> 1.25 % 0.5 meaning how many times do 0.5 goes in 1.25. answer = 2.5 remainder
+ 7
for your example
5 // 2 equals to 2 remainder 1 but your answer should be 2 because floor division operator sign will display the times 2 goes in 5 not the remainder therefore:
5 // 2 = 2
300 // 10 = 30
- 1
ora hai capito?