Because during an assignment, the RHS is evaluated first and the result is assignment to the given identifier. In this case, the `x` on the RHS was a function and the result (1 + x() = 1 + 2) was REASSIGNED/BOUND to the same identifier. Post reassignment, x is bound to a int literal, while before it was bound to a function.
I hope this snippet will help: https://prnt.sc/u1u8ki
def x(i):
print(i)
return i
x=x(1)+x(2)
Expression is evaluated from left to right, function return takes more precedence then followed by operator and finally value is assigned which is of least precedence. Above example would illustrate it.
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
clacot
Highly Voted 4 years, 3 months agolasagne394
4 years, 3 months agoclacot
4 years, 3 months agonatlal
Most Recent 10 months, 1 week ago34_trt
1 year, 2 months agomacxsz
2 years, 7 months agowolverin3
4 years ago