+254 728 680 519

Downloading and installing Python

There are several ways to get your own copy of Python 3, depending on the operating system you use. Linux users most probably have Python already installed - this is the most likely scenario, as Python's infrastructure is intensively used by many Linux OS components. For example, some distributors may couple their specific tools together with the system and many of these tools, like package managers, are often written in Python. Some parts of graphical environments available in the Linux world may use Python, too. If you're a Linux user, open the terminal/console, and type: ‘python3’

All non-Linux users can download a copy at https://www.python.org/downloads/

Because the browser tells the site you've entered the OS you use, the only step you have to take is to click the appropriate Python version you want.  In this case, select Python 3. The site always offers you the latest version of it.  If you're a Windows user, start the downloaded .exe file and follow all the steps. Leave the default settings the installer suggests for now, with one exception - look at the checkbox named Add Python 3.x to PATH and check it.   This will make things easier.

If you're a macOS user, a version of Python 2 may already have been preinstalled on your computer, but since we will be working with Python 3, you will still need to download and install the relevant .pkg file from the Python site. Now that you have Python 3 installed, it's time to check if it works and make the very first use of it. This will be a very simple procedure, but it should be enough to convince you that the Python environment is complete and functional. There are many ways of utilizing Python, especially if you're going to be a Python developer.

To start your work, you need the following tools:

  • an editor which will support you in writing the code (it should have some special features, not available in simple tools); this dedicated editor will give you more than the standard OS equipment;
  • a console in which you can launch your newly written code and stop it forcibly when it gets out of control;
  • a tool named a debugger, able to launch your code step by step and allowing you to inspect it at each moment of execution.

Besides its many useful components, the Python 3 standard installation contains a very simple but extremely useful application named IDLE. IDLE is an acronym: Integrated Development and Learning Environment.  Navigate through your IDLE is an acronym: Integrated Development and Learning Environment. OS menus find IDLE somewhere under Python 3.x and launch it. This is what you should see:

P.S I have edited mine a little bit the background should be white. I like this one much better

 

.

 

How to write and run your very first program

It is now time to write and run your first Python 3 program. It will be very simple, for now. The first step is to create a new source file and fill it with code. Click File in the IDLE’s menu and choose new file.

 

As you can see, IDLE opens a new window for you. You can use it to write and amend your code. This is the editor window. Its only purpose is to be a workplace in which your source code is treated. Do not confuse the editor window with the shell window. They perform different functions. The editor window is currently untitled, but it's good practice to start work by naming the source file.

Click File (in the new window), then click Save as..., select a folder for the new file (the desktop is a good place for your first programming attempts) and chose a name for the new file.

 

Put in your code as above and run the code by pressing F5 if you are a windows user. Congratulations you just created your first program. Now let’s go a little bit deeper down the rabbit hole.

 

Jesse

Playing Basketball, Arsenal fan, Python, and coffee!