Hello world

Objectives

The aim of this exercise is to learn how to write and execute Python code.

Rationale

There are plenty of programing languages, but all of them share some common principles. Computers execute machine code, a binary set of instructions that are carried out by the computer processors, but usually human do not write binary machine code, or even assembly language, the written code directly translatable to machine code.

Most of the time programers write code in languages that are easier to write and read by us, humans. These codes, in turn, have to be translated to machine code. This process of translation is called compilation. Compilation is a complex process that comprises several steps, and different compilers and programming languages divide theses steps differently. There are compilers, like the C or C++ compiles, that take the code and compile it into a binary executable that can be directly run in a computer, while there are other, like the Python interpreter of the Java compiler, that are capable of running directly the human readable code that create an intermediate representation called bytecode. In these cases we need to install the language interpreter to run the program. For instance, if you want to run a Java or Python program you will need to install Java or Python before.

Python is an interpreted language, so, once you install Python you will be able to directly run Python code. However, you first need to have Python available in your computer.

There are many ways of installing Python like:

  • Downloading Python from python.org.
  • Using the Windows store or the Linux packages already prepared.
  • Using a Python version manager like uv.
  • Having Python included in your web browser thanks to Pyodide.

In this exercise we are going to use Pyodide, a Python version that allow us to run Python code directly in a web page without requiring any previous installation.

The Notebook document is composed by cells, some are text (in markdown format), and others contain Python code that can be executed. To execute a Python cell:

  • Select the cell that you want to execute.
  • Click the play symbol on top of the page or press shift + enter.