Skip to content

Python

In this article, we’ll explore the core concepts that make Python one of the most used programming languages, how to install it, and the main tools used by researchers and engineers.

Python

Python, created by Guido van Rossum in the early 1990s, is a programming language known for its simplicity, readability, and versatility. Its clean syntax makes code easier to read and write compared with languages such as C, C++, and Rust.

Guido van Rossum
Guido van Rossum. Credit: Michael Cavotta.

Python uses dynamic typing, which means you don’t need to specify whether a variable is a number, a string, or another type when you create it. The interpreter determines the type during runtime, making Python more flexible compared to statically typed languages like C++ or Rust.

For example, in Python, you can write:

message = "My awesome message!"

In contrast, C++ requires specifying the variable type:

std::string message = "My awesome message!";

Another feature of Python is its clean and readable syntax, which often requires fewer lines of code compared to other programming languages.

For instance, printing “Hello, World!” in Python is as straightforward as:

print("Hello, World!")

In C++, even a simple program like this requires additional code:

#include <iostream>
int main() {
cout << "Hello, World!" << endl;
return 0;
}

Python is an interpreted language, which means its code is executed line by line without the need for a prior compilation step. This allows for immediate testing and debugging but can result in slower execution speeds compared to compiled languages like C++ or Rust, where code is translated into machine code before execution. While compilation adds an extra step, it often results in faster runtime performance.

There are several ways to install Python. I recommend using the uv package manager, which can help you with tasks such as:

  • Installing and managing specific Python versions
  • Creating and managing virtual environments
  • Installing and managing Python packages and tools
  • Replacing several tools, including conda, pyenv, pip, poetry, virtualenv, and more

To install uv, open the Terminal or PowerShell and paste the following code:

Terminal window
curl -LsSf https://astral.sh/uv/install.sh | sh

To install Python, enter the following code in the Terminal or PowerShell:

  1. Update the shell PATH:

    Terminal window
    uv tool update-shell
  2. Install Python:

    Terminal window
    uv python install 3.14

In this article, we’ll explore three ways to run Python code:

  1. The Python interpreter for quick feedback
  2. IPython for an interactive development experience
  3. JupyterLab for developing complex, interactive projects

The Python interpreter is ideal for quick testing and run simple scripts.

  1. Launch the Python interpreter:

    Terminal window
    uv run python

    You’ll see something like this:

    Terminal window
    uv run python
    Python 3.14.7 (main, Sep 1 2026, 14:05:28)
    Type "help", "credits" or "license" for more information.
    >>>
  2. Hello, world!

    Tradition suggests that the first program in a new language should print the words Hello, world! on the screen. In Python, this can be done in a single line:

    print("Hello, world!")

    Type it into the Python interpreter:

    >>> print("Hello, world!")
    Hello, world!

    Try calculating the sum of the first 5 natural numbers:

    >>> 1 + 2 + 3 + 4 + 5
    15

IPython offers code completion, syntax highlighting, and the ability to execute code line by line. It is great for interactive learning and experimentation.

  1. Install IPython:

    Terminal window
    uv tool install ipython --with pip
  2. Launch IPython:

    Terminal window
    ipython

    You’ll see something like this:

    Terminal window
    Python 3.14.7 (main, Sep 1 2026, 14:05:28)
    IPython 9.17.1 -- An enhanced Interactive Python.
    In [1]:
  3. Exploring Tab Completion:

    IPython’s tab completion lets you complete code with a single press of the Tab key. This simple feature reduces typos and saves time.

    For example, type pr in IPython and press Tab:

    In [1]: pr
    print() property %precision %prun

    Select print( ) and complete the "Hello, world!" example:

    In [1]: print("Hello, world!")
    Hello, world!
  4. Discovering Object Attribute Completion:

    In Python, attributes describe an object, while methods define what it can do. IPython’s object attribute completion makes it easy to discover both.

    For example, create a string:

    In [2]: name = "Marcos"

    Then type name. and press Tab to see the string’s available attributes and methods:

    In [3]: name.
    capitalize() lower() upper() ...

JupyterLab is a web application for creating interactive documents that combine code, text, equations, and rich visuals. It provides Python developers with an intuitive environment for coding and experimentation.

  1. Install JupyterLab:

    Terminal window
    uv tool install jupyterlab --with altair

    This will install JupyterLab with the Altair extension that allows us to create interactive visualizations.

  2. Launch JupyterLab:

    Terminal window
    jupyter-lab

    This will launch the JupyterLab server and automatically open it in your web browser.

    JupyterLab

  3. Ploting a sine wave:

    Here’s how to create a sine wave plot using Altair, a library for interactive visualizations. Our main focus is to present JupyterLab’s functionality, so don’t worry about understanding the code just yet.

    Create a new notebook by selecting File → New → Notebook, then paste the code below:

    import altair as alt
    data = alt.sequence(0, 10, 0.1, as_='x')
    alt.Chart(data).transform_calculate(
    y='sin(datum.x)'
    ).mark_line().encode(
    x='x:Q',
    y='y:Q',
    ).properties(
    width=768,
    height=300
    )

    To run the code, use Shift + Enter:

    JupyterLab Plot

Create a new Python project:

Terminal window
uv init hello-world

Run the hello-world main.py example:

Terminal window
uv run ./hello-world/main.py

uv will create the following files:

  • Directoryhello-world
    • .git
    • Directory.venv
      • bin
      • lib
      • pyvenv.cfg
    • .gitignore
    • main.py
    • pyproject.toml
    • README.md
    • uv.lock

Create a virtual environment:

Terminal window
uv venv

You can create a virtual environment with a specific Python version:

Terminal window
uv venv --python 3.14

Activate the virtual environment:

Terminal window
source .venv/bin/activate

Install a package in the virtual environment:

Terminal window
uv pip install ...

List all installed packages in the virtual environment:

Terminal window
uv pip list

Exit the virtual environment:

Terminal window
deactivate

So, that’s a quick tour of Python and the tools you’ll use to get started.

You’ve learned how Python’s simple syntax and dynamic typing make it approachable, how to install Python with uv, and how to run code with the Python interpreter, IPython, and JupyterLab. You also saw how uv can help you create projects, manage Python versions, and work with virtual environments.

There’s a lot more to Python, of course, but you don’t need to learn everything at once. Pick a small project, open your favorite environment, and start experimenting. That’s where things really start to click.

Happy coding!