top of page

In this video, I have taught
Operators
An expression is made up of variables, constants, and operators.
For example - 15-5 * 20.
Precedence plays an important role when more than one operator is involved in an expression. To evaluate these types of expressions, there is rule of precedence in Python.
In dictates the order of evaluation of operators in an expression. The level of operator precedence is high to low. A higher level precedency operator is evaluated first.
To know the precedence of the operator, follow the given table:
Consider the following example: 24 +5*4
Here we have an expression which contains two operators + and *. Which operator do you think will be evaluated first-addition or multiplication? If addition is applied first, then the answer will be 116 and if multiplication is applied first, the answer will be 44.To answer such question, we need to look at the operator precedence table.
As a result, the operator with higher precedence is evaluated before the operator with lower precedence. Thus, from the precedence table, we can conclude that the * operator is above the operator, so the * operator has higher precedence then the + operator, therefore 5 * 4 will be evaluated first.
24+5*4
24+20
44
Thus, 44 is the answer.
bottom of page