Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12201

Regarding left-sided Binding in Python

$
0
0

I'm new to Python and I'm still learning. I've learned the concept of left-sided binding when using operators (and it was taught that only exponentiation uses RIGHT-SIDED BINDING). It was also taught to me that, both * and / have equal priority and Binding of the operator determines the order of computation performed by some operators with equal priority, put side by side in one expression.

But now when teaching compound assignment operators, they used the following example

a = 6b = 3a /= 2 * bprint(a)

The answer given is 1.0.

The explanation they have given is as follows.

2 * b = 6

a = 6 → 6 / 6 = 1.0

My question is, isn't a/=2*b is the same thing as a=a/2*b. So when considering a=a/2*b shouldn't the division be considered first becuase of the left sided binding and then the multiplication later.

a = 6 → 6/2 = 3.0

3.0 * b = 9.0.

So shouldn't 9.0 be the answer. Please explain this to me.


Viewing all articles
Browse latest Browse all 12201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>