exec(expr, {'x':1,'y':2}) This sentence is obvious: 31+2=33
exec(expr, {' x':1,'y':2}, {'y':3,'z':4}):
x is passed in 1, y is passed in first It is 2, and the second pass is 3, which covers the previous 2. So y is 3, and z is passed in 4.
But in expr, z is reassigned 30, so the result is 31+3=34