Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Python software


1. Python software
Python

2. Python
Python is a general purpose programming language.

Python is powerful... and fast; plays well with others; runs everywhere; is friendly & easy to learn; is Open. From the Python web site at https://www.python.org/ .

3. CentOS installation
The CentOS repository has the older Python 2.7.5. The newer version is 3.x.

Since yum may break if we are not careful, we will use Python 2.7.5 for now.

4. Verify the version
The following Linux command(s) check the installed version of Python.
python --version

On 2019-08-04 the output was as follows.
Python 2.7.5


5. Interactive mode
The following Linux command(s) enter interactive mode.
python

Then type the following commands interactively, pressing Enter after each command. Press Ctrl-D to exit interactive mode.
4+3

The output should be as follows.
7


6. Hello world in Python
The file type of a Python program file is py.

The following Linux command(s) create/edit a hello program in the your home directory using the nano text editor.
nano ~/hello.py

Create the following program text in the editor that will output the text "Hello world"
print("Hello world")

To exit with save, remember to press Ctrl-X, then "y" (for yes) and Enter to exit.

The following Linux command(s) run the program.
python ~/hello.py

The output should be as follows.
Hello world


7. End of page