On the command line one can type:

python -V

To run some Python code without creating a file, type

python -c "print 42"
python3 -c "print(42)"

Type the following to get the details:

man python

cmdline