Q:

How to solve Long Python expressions?

I'm fairly new to programming and am learning Python. I wanna ask the order in which simple arithmetic expressions of python are solved. I mean e.g there is a simple question 10 / 2 * 5 - 2.
Now, in which order will it be solved? Like first division, then multiplication, then subtraction like in DMAS rule or is there some other rule.
Also, if there is a question, 10 % 5 % 3, I'm confused at these long Modulo expressions, so please help me.

A:

Expressions are resolved using the documented operator precedence table.
This means that multiplication and division comes before subtraction, with operators of equal precedence being applied from left to right, so the expression can be read as:
((10 / 2) * 5) - 2

The same applies to the modulo operator; the operations are applied from left to right:
(10 % 5) % 3

