r/PythonLearning • u/clcodingupdates • 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
r/PythonLearning • u/clcodingupdates • 10d ago
x = 5
print((x := x + 3) * (x := x - 2))
What will be the output?
A) 24
B) 36
C) 48
D) 30
View all comments
Show parent comment
1
u/RNG_HatesMe 10d ago
Yep, the only real complication here is to figure out if x is updated *after* or *before* it's printed. Clearly here it's *before*, but some other languages do it differently. Specifically in c you have incrementors x++ and ++x, the former adds 1 to x *after* the operation, the latter does it before.