+ 2
please explain this to me đ(θâżÎ¸)
uses of this signs and their meanings ** // %
3 Answers
+ 6
3**2 = 3*3 = 9 (exponentiation)
5//2 = 5/2 = 2.5 = 2 (integer division)
5%2 = 5 - 2*2 = 1 (modulo division)
+ 1
x ** y, raises x to the exponent, y. x // y, performs floor division. x % y, returns the remainder of dividing x by y.
+ 1
** is exponential operator
example 2 ** 2 = 4
this is easy to remember.
2 ** (how many times you want to multiply 2 by itself)
// is floor/integer division operator
the result of division in Python is float by default.
if you use division 5 / 2 the result is 2.5. but using //, the result is 2. it always drops the numbers after decimal point.
% is the remainder/modulo operator. it returns the remainder result. if you divide 5 by 2, theres remainder 1. to get the remainder, we use %.
5 % 2 = 1