Skip to content

Setting up a small Project

Organization is Everything

When starting an new project, be it programming or otherwise, it is a good idea to first create a new folder in which all files for the project are placed. In the following, this will be called the top-level or root folder.

Create a new folder in a location where you prefer to have your projects (e.g. your desktop, or documents or home folder…) and call it alien_growth_model. In this folder we will put all our files for this example project.

The main thing

Python code can be written into one or more files and organized in so called modules. Python files end with .py.

Each program, be it in one or more files, will need a well-defined starting point. By convention the file containing this starting point is called

This could be your current structure now:

📁 alien_growth_model

The double underscores __

Surrounding the name of something (files, code elements, …) with double underscores __ usually holds a special meaning: This is important for the internal working of Python itself.

You should not lightly name things with __ and be extra careful when using these things.

With the project folder and the file set up, we are ready to get started.


Sometimes, all you want to do is to have a small file with a few lines of code in it instead of a whole project. These files are called scripts and instead of a project folder on their own, most developers tend to sort them into a collective folder or put them next to the data files the program works with. These scripts then also tend to get a more descriptive name, like

Interacting with Python

To run any Python code on your computer you need to use an interpreter program. It translates the code into the machine language that your computer uses and also translates the answers back into something you can read. The interpreter program is also called python.

The Python interpreter can be used in two ways:

  1. Writing a file with code in it, which then gets processed by the interpreter.
  2. Entering an interactive session (called REPL) with the interpreter and issuing the commands one-by-one with direct feedback.

In practise you will often use the first option for code you intend to keep and the second to experiment around. Many tools also allow you to also continue with an REPL after procesing a file.

Way 1: Running Python from a file

To write a Python file, any plain-text editor is sufficient (although having a dedicated tool for Python is extremely helpful). Python files themselves are plain text files with the ending .py. To run them, most tools have a dedicated button, that looks like a play-button. Alternatively you can pass them into the python command on the command line.

Assuming your project folder is called my_project and has a file inside:

python my_project

or, in slightly older versions of python:

python -m my_project

Assuming you have file called


Don’t forget to save any changes before running the file or Python will not see the current version.

Way 2: REPL

The abbreviation stands for Read user input, Evaluate, Print result, Loop to the first step. It describes an interaction that feels like an text-chat with a computer.

Many tools offer a Python console window for that purpose or you can run the command python (without any added parameters) on the command line.


There is also a tool called ipython available for the command line which is quite more comfortable than the regular python command when doing REPL.

Now you!

Here is a very first Python program to try out:

print("Hello World!")

Try to run it as a REPL and by writing it into a file called and running the file.

Starting the Work on our Program

For our current project we will start by creating a project folder called alien_growth_model. Inside we add the file Let’s also add a line of code inside this main file so we can see if everything is working as intended:

print("The Alien Growth Model")

We will learn the details of how this works later on. For now, we need to understand that print(…) is a function that outputs a given value on the screen. The " around The Alien Growth Model denotes literal text as opposed to something that might be program code.

Now you

Try to run the project in your python interpreter. If you are using the command line, pay attention that your working directory should be the one above your project folder.

Key Points

  • Python code can either be written in files or used interactively in a REPL
  • Python files are plain text and end in .py
  • Writing code in files is good for storing and sharing code
  • The REPL is practical for experimentation
  • Python projects tend to be in their own folder and have a file that acts as the starting point

Code Checkpoint

This is the code that we have so far: