+ 1

quotient and reamainder

read and explain this please This code shows that 6 goes into 20 three times, and the remainder when 1.25 is divided by 0.5 is 0.25. >>> 20 // 6 3 >>> 1.25 % 0.5 0.25

8th Dec 2016, 8:34 PM
Khamari White
1 Resposta
+ 7
Yes Khamari 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 0.25. Hey don't forget we say this sign only display the remainder as answer not the times it goes, therefore your answer will be displayed as 0.25 not 2.5 Hope you understand...?
9th Dec 2016, 1:49 AM
Xperience
Xperience - avatar