The % operator in Python is the modulo operator, which returns the remainder of the division of the left operand by the right operand. In the expression 3 % -2, the remainder of the division of 3 by -2 is calculated. The result is -1, because when 3 is divided by -2, the quotient is -2 with a remainder of -1. Therefore, print(3 % -2) will output -1.
0 Comments:
Post a Comment