Python | Installation and first program

I am a Linux user and Python is installed in all Linux distributions. As I know, it is installed on Mac computers as well. Some of the Windows laptops come with Python installed. First, you have to check if you have Python installed. Open the terminal and run the command python.

Python on Linux

Once Python is started you can type code directly in terminal. That would be just fine for now.

Python in action on Linux

As you can see, Python performs different tasks immediately after they are typed. The code you type in the terminal is not saved anywhere. The terminal is useful for testing purposes.

To write an entire program you have to use an editor. There is an editor that comes with Ubuntu (the Linux distribution I use) which is called gedit. You can use whatever text editor you want, the result will be the same.

So, open the editor and type the following line of code.

print(‘Hello there’)

First program in Python

This is how my editor with the code looks like. You have to save it in the desired location and give the file the extension .py. I saved the file as in the Documents directory on my computer. Now, you can execute the file via terminal.

First, I changed the directory where my file is by running the command cd Documents. Once the directory is changed you can execute the Python program via terminal by running the command python Below is the result.

Executing the first Python program

This is pretty much it. That’s how you can create a simple Python program.

Leave a Reply