Python Addition & Concatenation
In Python, the Arithmetic
Operator "+" is used for two different purposes.
We can use it to Add two or more integer or float values.
We can use it to Concadinate two or more string values.
This only works with string data-type.
You can learn about Type convertions here.
concatenation links the values together without
performing any
arithmetic operation.
Here are few Arithmetic Operators.
| Operator | Description | Example |
|---|---|---|
| + Addition | Adds values on either side of the operator. | 10 + 20 = 30 |
| - Subtraction | Subtracts right hand operand from left hand operand. | 10 – 20 = -10 |
| * Multiplication | Multiplies values on either side of the operator | 20 * 10 = 200 |
| / Division | Divides left hand operand by right hand operand. Output is a float value. | 8 / 4 = 2.0 |
| % Modulus | Divides left hand operand by right hand operand and returns remainder | 5 % 2 = 1 |
| ** Exponent | Performs exponential (power) calculation on operators | 10**2 =100 |
| // | Floor Division - The division of operands where the result is the quotient in which the digits after the decimal point are removed. | 9//2 = 4 9.0//2.0 = 4.0 -11//3 = -4 -11.0//3 = -4.0 |