+ 1
What are floor division and modulo operators
2 Réponses
+ 5
Floor division(x//y) returns the quotien in which the digits after the decimal point are removed.
Ex:-
10 // 3
3 (output)
# 3.333 rounds towards zero
10 // -3
-4 (output)
# -3.333 rounds away from zero
9 // 2
4 (output)
# 4.5 rounds towards zero
9 // -2
-5(output)
# -4.5 rounds away from zero
Modulo(x%y) returns the remainder .
Ex:
10%3
1(output)
10/3 ,quotien =3 and remainder=1
15%4
3(output)
15/4 ,quotien =3 and remainder=3
+ 1
Thank you so much sir.