+ 1

What is floor division and modulo operators in Phython 3 i don’t understand please give me answer and examples

floor division = // modulo = %

2nd Jun 2019, 12:07 PM
Rupak Barman
Rupak Barman - avatar
2 Réponses
+ 1
>> Floor division (//) This operation means to divide a number by a certain number, and return its answer without the decimal value. Example: 20÷8 = 2.5 So, therefore, 20//8 = 2 Other examples: 5//2 = 2 7//3 = 2 >> Modulo (%) The modulo returns the remainder when a number is divided by another number. If 20÷8 returns a remainder of 4, therefore, 20%8 = 4 Other examples: 5%2 = 1 7%4 = 3 While on the other hand, if the left number is greater than the right number, the answer is always the left number. Example: 1%5 = 1 10%12 = 10 etc. :)
2nd Jun 2019, 12:25 PM
Kazuki Hiromoshito
Kazuki Hiromoshito - avatar