In / and % which of the two is higher in precedence because they usually get interchanged | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

In / and % which of the two is higher in precedence because they usually get interchanged

31st Oct 2020, 4:29 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar
4 Antworten
+ 4
Seb TheS Yes u were right . * , / , % has same precedence and just gets evaluated from left to right..👍
1st Nov 2020, 4:37 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 2
Eskay👑👑 you should say which language you mean. In Python the are evaluated from left to right by definition. Right to left (or defining different precedence levels) would change the result obviously, but that's not how it works
31st Oct 2020, 5:41 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 2
Alphin K Sajan If / has higher precedence than %, then 10 % 8 / 2 should evaluate to 10 % 4.0 causing result 2.0. But 10 % 8 / 2 gives result 1.0.
31st Oct 2020, 9:40 PM
Seb TheS
Seb TheS - avatar
+ 1
What about solving the expression from right to left, won't it change
31st Oct 2020, 4:35 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar