Update to Python samples: Fixed shebangs, added error checking

This was my attempt to fix some common mistakes noticed throughout the samples.
I added some minor reorganization and categorization of imports, error checking for loaded files, and a replacement of calling "python" with sys.executable. The last is useful if the user is not using the system's default "python".

Note that these code changes were not tested, as they were both simple and across a wide range of files.