I am trying to understand the reason why the whole Python process does not get killed when I press Ctrl + C inside and infinite loop or for that matter any Python function that I am running in terminal and only the loop/function is stopped?
It's because of the design of the Python interpreter and interactive session.
If the interpreter is running in an interactive session (i.e. by running
python3 at the console), then the exception in the current function is printed and you return to the Python prompt. If the interpreter is running a script (e.g. by
python3 my_script.py), then unless the KeyboardInterrupt is handled by the script, the whole program will stop when the exception is raised.