PYTHON_101 | PYTHON COMPARISON OPERATORS
SMARS Learning Platform
78% Complete
PYTHON_101 | PYTHON COMPARISON OPERATORS
Operator | Symbol | Description | Example |
---|---|---|---|
Equals | = |
Assigns values from right side operands to left side operand | c = a + b assigns value of a + b into c |
Add AND | += |
It adds right operand to the left operand and assign the result to left operand | c += a is equivalent to c = c + a |
Subtract AND | -= |
It subtracts right operand from the left operand and assign the result to left operand | c -= a is equivalent to c = c - a |
Multiply AND | *= |
It multiplies right operand with the left operand and assign the result to left operand | c *= a is equivalent to c = c * a |
Divide AND | /= |
It divides left operand with the right operand and assign the result to left operand | c /= a is equivalent to c = c / a |
Modulus AND | %= |
It takes modulus using two operands and assign the result to left operand | c %= a is equivalent to c = c % a |
Exponent AND | **= |
Performs exponential (power) calculation on operators and assign value to the left operand | c **= a is equivalent to c = c ** a |
Floor Division | //= |
It performs floor division on operators and assign value to the left operand | c //= a is equivalent to c = c // a |