From the command line:

$ python -c "print 'Hello World!'"

Create a file hello.py:

print 'Hello World!'

and then (from command line):

$ python hello.py

Add at the top of your file: (and make it executable)

#!/usr/bin/python

and then (from command line):

$ ./hello.py

Interactive python shell:

$ python

now you can enter any python code:

>>> print 'Hello World!'
Hello World!
>>> (352+817)*781
912989