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.

#addition of intergers x = 3 + 5 print("x =",x) #addition of floats y = 3.5 + 5.5 print("y =",y) #addition of float and integer z = 3 + 5.5 print("z =",z)
Press Run to execute.

We can use it to Concadinate two or more string values.

This only works with string data-type.

x = "hello" + "world" print(x) #convert integer values to string and concadinate y = str(50) z = str(100) r = y + z print(r)
Press Run to execute.

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





Concept & Design by Code94 Labs