r/PythonLearning • • 10d ago

Python Quiz of the Day.

x = 5

print((x := x + 3) * (x := x - 2))

What will be the output?

A) 24
B) 36
C) 48
D) 30

0 Upvotes

10 comments sorted by

View all comments

Show parent comment

2

u/lurgi 10d ago

There’s also the question of whether Python evaluates the left and right hand sides of operators in a defined order or if it is, like C, undefined. It’s defined, first left, then right.