Arithmetic operator
Arithmetic operators in Python are used to perform mathematical calculations on numerical operands. Here are the arithmetic operators in Python:
- Addition (+): Adds two operands.
a = 5
b = 3
result = a + b # result = 8
- Subtraction (-): Subtracts the second operand from the first.
a = 10
b = 4
result = a – b # result = 6
- Multiplication (*): Multiplies two operands.
a = 7
b = 2
result = a * b # result = 14
- Division (/): Divides the first operand by the second.
a = 70
b = 2
result = a /b # result = 35.0
- Modulus (%): Returns the remainder after division.
a = 17
b = 5
result = a %b # result = 2
- Exponentiation (**): Raises the first operand to the power of the second.
a = 3
b = 4
result = a ** b # result = 81
- Floor Division (//): Returns the integer value of the division result.
a = 10
b = 4
result = a /b # result = 2
These arithmetic operators can be used with numeric data types like integers and floating-point numbers to perform calculations and obtain results based on the desired operation.