1. Arithmetic Operators:
Definition: These are special symbols used to
perform basic mathematical calculations within code. They handle standard
operations like addition, subtraction, multiplication, and division. Any
operator that performs a fundamental math task falls into this category.
List of Operators:
- + :
Addition (Adds two values)
- - :
Subtraction (Subtracts one value from another)
- * :
Multiplication (Multiplies two values)
- / :
Division (Divides and gives a decimal result)
- % :
Modulus (Divides and gives only the Remainder)
- **
: Exponentiation (Calculates the Power, e.g., $2^3$)
For Example,
2.
Priority Theory (Precedence):
Definition: It is a term or rule used to decide
which calculation happens first when we write multiple operators in a single
line of code. It prioritizes the operations based on standard math rules,
meaning it solves Brackets/Parentheses () first, then Powers/Exponents,
then Multiplication or Division, and lastly Addition or Subtraction.
The
Priority Order (First to Last):
- () : Brackets (The Boss - always
first)
- ** : Power
- *, /, % : Multiply, Divide, Remainder
- +, - : Add, Subtract
For Example,
3.
PEMDAS Rule:
Definition: It is a short formula or rule used
to easily remember the order of Priority Theory. It stands for the sequence in
which Python solves mathematical parts of the code, starting from Parentheses
and ending with Subtraction.
The Full Form:
- P - Parentheses ()
- E - Exponents ** (Powers)
- M
/ D - Multiplication
* & Division / (These are equal, so Python solves them Left
to Right)
- A / S - Addition + & Subtraction - (These are equal, so Python solves them Left to Right)
For Example,
4.
BODMAS Rule:
Definition: It is a popular rule used to
remember the priority of mathematical operations in code. It helps us decide
which part of a calculation to solve first. It stands for the sequence starting
from Brackets and ending with Subtraction.
The Full Form:
- B - Brackets () (Same
as Parentheses)
- O - Orders ** (Powers,
Exponents, or Roots)
- D
/ M - Division
/ & Multiplication * (Solved Left to Right)
- A / S - Addition + & Subtraction - (Solved Left to Right)
For Example,
Comments
Post a Comment