MWZ

MINDWAREZONE

Operator Precedence in python

Python follows a specific order when evaluating operators.

Example

result = 10 + 5 * 2 

print(result)
            

Output:

20
            

Multiplication is performed before addition.

You can use parentheses to change the order.

result = (10 + 5) * 2 
print(result)
            

Output:

30