the variable
opreations
is a dictionary which contains the function characters as the keys, and the actual functions as the values. So when the user enters '+' the
calculator_function
will be set to point to the
add
function. and the next line:
answer = round(calculator_function(num_1, num_2))
Will call that function.
You can see this in action by running the code through
pdb — The Python Debugger — Python 3.10.2 documentation[
^]