Introduction
Operations in python: In this post, you will learn the different types of arithmetic operations and also you will learn some of the examples and below is the video format of the post, check it out ????????
Video:
Arithmetic operations in python ❓
Arithmetic operators are used for performing mathematical operations like addition, subtraction, multiplication and division…
In simple, I can these operators make a meaningful code, without these operations most of the code cannot be fullfilled
There are 7 arithmetic operators in Python;
- Addition
- Subtraction
- Multiplication
- Division
- Modulus
- Exponentiation
- Floor division
In this list, we can add parenthesis also and let me teach you, step by step what all the arithmetic operations do…
Remember most of the time you will be using PEMDASLR,
P: Parenthesis ()
E: Exponent
M: Multiplication
D: Division
A: Addition
S: Subtraction
L: Left
R: Right
*I have added left and right also, you may ask they are not operators.
Yes, they are not operators but I am trying to tell is whatever the value you enter inside the () it will be calculated from left to right.
Addition operations in python
As you know addition will add two values the same will happen in python code also.
Result:
Subtraction
The subtraction just minus the values, as we see in our lower grade classes
Result:
Multiplication
In your older grades, you will be using X as the multiplication symbol but in python, the multiplication operator is *
Result:
Division operations in python
In python division, we use this operator /
While doing division we can see, that the result comes in float format and to change it use type conversion.
Exponent
For exponent, we use the ** function.
For eg: 8**2
It is 8 to the power 2.
Also Read: Type function in python full tutorial
Also Read: Data types in python full tutorial