How to auto run a simple python program when the terminal opens
You can put command to run the script in .bashrc file inside your home directory, this file is read every time you open non-login shell (Terminal, Iterm and their tabs).

python /path/to/foo.py


Don't forget to set the permissions for all to execute:

chmod a+x foo.py