there should be an error when this code is run. as I have not defined the arguments (I was told by my computer science teacher that it should not work in theory) and parameters but it clearly works.
Yes, this conforms to Python's namespace/scoping rules: nested scopes are allowed to reference (but not assign to) variables from the global scope even without a 'global' declaration.
Abdullah, in the future, please upload or post runnable Python code, not an image. Output can be copied into a message. If you think IDLE is doing something wrong, test by running the code directly with Python. If your file is test.py, enter the following on a Command Prompt command line. path-to-your-python-code-dir> python -m test.py There would only be an IDLE issue (and then only maybe) if the code ran differently or produced different output in IDLE than with python directly. That is not the case here.