Python Operator
Operators in Python
An operator is defined as :
The Operator is a sign or symbol that tells the computer to perform an operation.
We study the following operator :
1. Arithmetic Operator
2. Comparision Operator
3. Logical Operator
4. Bitwise Operator
5. Assignment Operator
6. Membership Operator
7. Identity Operator
1. Arithmetic Operator
The Arithmetic Operators are used to perform an arithmetic operation. It calculates the numerical calculations. It performs addition, multiplication, subtraction, division, remainder, and power.The symbols are: + , * , - , / , //, % , and **. We see some examples.
- Addition:
a = 4 + 5
In this example, the addition operator adds 4 and 5, and the result 9 fills in variable a. Similarly we can add numbers more than two numbers.
- Multiplication:
a = 7 * 8
In this example, the multiplication operator multiplies 7 and 8, and the result 56 fills in variable a. Similarly we can multiply numbers more than two numbers. We use the stearic '*' symbol to perform multiplication. The '**' use for power(a² ==> a ** 2).
- Subtraction:
In this example, the subtraction operator subtracts 3 from 9, and the result 6 fills in variable a. Similarly we can add numbers more than two numbers.
- Division:
a = 10 / 5
In this example, the division operator divides 10 by 5, and the result 2.0 fills in variable a. The single '/' return value in real form. On the other hand the '//' returns an integer(as 2).
- Remainder/Modulus:
a = 10 // 5
In this example, the remainder operator finds the remaining value of the operands. In the above example, the remainder is 0.
Comments
Post a Comment