Hello World in Python


Python Version

Print the Python version number and exit. Example output could be:

Python version
python -V
python --version
Python 3.9.1

Running Files with Command Lines

You can ask Python to run it by listing its full filename as the first argument to a python command like the following typed at the system shell prompt.

python hellowrold.py

Type the following statements into a new text file named hellowrold.py:

# A first Python script
# hellowrold.py


The Interactive Prompt

Assuming the interpreter is installed as an executable program on your system, the most platform- neutral way to start an interactive interpreter session is usually just to type python at your operating system’s prompt, without any arguments. For example:

Python 3.9.1 (default, Oct 15 2021, 22:19:38) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.

On Windows, a Ctrl-Z gets you out of this session; on Unix, try Ctrl-D instead.

Related Tags