> In Python where does the modulus or % fit in operator precedence?

In Python where does the modulus or % fit in operator precedence?

Posted at: 2014-12-18 
My class doesn't say anything about that.

It's grouped with multplication and division operators: * / % and // all have the same precedence, and associate from left to right as a group.

Modulo really is just integer division...giving you a remainder instead of a quotient...so it makes sense to group it there. Every other language I've seen that uses the C-inspired % for mod/remainder does the same thing.

Did you even try searching? If you simply googled " python operator precedence", the very first result would have led you to the answer.

If you are writing a program, and there's any doubt in your mind, use

parentheses to remove doubt. Programs need to be clear for other people to read quickly. If you're taking a test, then look it up in the

textbook, or in an online text, and don't be so lazy. But in general,

avoid obscurity, and don't avoid the manual.

>

> John (gnujohn)

You shouldn't depend on your class to teach you operator precedence when you can easily find such things by searching for

python operator precedence

https://docs.python.org/2/reference/expr...

My class doesn't say anything about that.