In this video, I have covered how to use numbers like integers, floats and performed basic Arithmetic operators and covered various operators with examples.
NUMBERS AND OPERATORS
Numbers are normal operand values which are used to perform set of task or operations using an operator. Numbers can be integers, decimal value, etc.
There are many operators in Python. Some of them are listed below:
1) Arithmetic operators
2) Comparison operators
3) Logical operators
4) Bitwise operators
5) Assignment operators
In this blog we will see about Arithmetic operators and understand how to use it with Python IDLE to perform certain calculations.
PYTHON ARITHMETIC OPERATORS
OPERATOR | DESCRIPTION | EXAMPLE |
Addition (+) | Adds two values | 5+6 = 11 |
Subtraction (-) | Subtracts | 5-3 = 2 |
Multiplication (*) | Multiplies two values | 4*8 = 32 |
Division (/) | Divide by right hand operand | 6/3 = 2 |
Modulus (%) | Divides and gives the remainder | 6%3 = 0 |
Exponential (**) | Performs power calculations on operand | 2**4 = 32 |
Double slash (//) | Rounds the float to the nearest value integer.Positive case: Round to positive existing integerNegative case: Round towards negative infinity | 13//2 = 6-13//2 = -7 |
The priority or hierarchy of operators is defined using a standard rule of BODMAS which means Brackets, Division, Multiplication, Addition and Subtraction. In this priority a given equation with multiple operators can be solved.
Other operators will be explained in other blogs.