Q:

Python - Code does not run without #!/usr/bin/python

Okay I am new to Python, but my code does not run if the line 
#!/usr/bin/python

is not present at the beginning of the file. Why is that ? What does it mean ? I thought it was used for to denote a python version if there were multiple versions installed.
#!/usr/bin/python
def main():
    a = [1,2,3]

    print a

if __name__ == "__main__":
  main()

Omitting the #!/usr/bin/python gives the following error only if I execute it using 
./test.py on Ubuntu
if however I use the python command to run then it runs fine without the /usr/bin line.

A:

The first line of the script beginning with #! is a shebang (sometimes called a hash-bang). 
The following executable path denotes which interpreter should be used to process the following code (in your case, /usr/bin/python). 
If you run the script from the shell with python test.py, you don't need a shebang - the executable is python and the script is passed to it as an argument.

