When setting a variable or sequence index to a function, do not use parentheses. Parentheses signify that the function should be called. If you use the function name by itself, the variable or index is instantiated to the function itself.
if_tree( MAIN_TEXT, ["1", "2"], ["Q", "H", "R"], [basic_option, advanced_option, quit_program, display_help, exec("restart_calculator()")] )Other than that, I believe this script should be refactored into a class called Calculator. The function input() returns a string so there is no need for str(input()).