What is operator precedence in python?

912    Asked by ananyaPawar in Data Science , Asked on Nov 12, 2019
Answered by Nitin Solanki

We learn before that there are many operators in python, as like in mathematics BODMAS rule we need to keep in mind that there is one order to execute these operators when more than one operator encountered in any calculation.

In python this operator precedence rule known as PEDMAS, where

P = Parentheses

E = Exponent

D = Division

M = Multiplication

A = Addition

S = Subtraction

Run below example and see how it works

a = 20 +20* 50/20

output = 70

a = (20 +20) * 50/20

output = 100



Your Answer

Interviews

Parent Categories