Logo

4,222 Introduction to Programming

Lecture 2: Getting Started

Dr. Franziska Bender, Dr. Aurélien Sallin

2026-02-20

Goals for today

In the next 45 minutes:

  • learn what a terminal is and why we use it
  • set up an efficient (and professional) programming environment with an IDE
  • install Python and understand environments
  • prepare everything needed for the next lectures

We will address main concepts in the lecture, and then get hands-on in the guided exercise session this afternoon.

Using a terminal

What is a terminal?

The terminal is a text-based interface that allows you to interact directly with your computer/operating system by typing commands.

Alternative names:

“terminal”, “command line”, “shell”, “command prompt”

Some terminology:

  • Terminal: the window where you type commands and see output
  • Shell: the program that interprets your commands (e.g. bash, zsh, PowerShell)


Why use a terminal

Almost everything you can do with a graphical interface can also be done from the terminal.

The terminal is often:

  • faster for repetitive tasks
  • more precise and reproducible
  • easier to automate
  • available on almost every system

Because of this, terminals are widely used in programming, data science, and research workflows.

Opening a terminal

macOS

How to open:

  • Press Cmd + Space
  • Type “Terminal”
  • Press Enter

Windows

How to open:

  • Open the Start menu
  • Search for “Command Prompt” or
    “Windows Terminal”

On Windows, you may see different terminals:

  • Command Prompt (CMD): lightweight, text-based, older (early days of Windows), very basic
  • PowerShell: modern, powerful, widely used, CMD on steroids
  • Windows Terminal: a modern app that can host both

For this course: Use Command Prompt in Windows Terminal.

Opening your terminal

Terminal

When you first open Terminal you typically are placed in your home directory. You can navigate to other directories (folders) using terminal commands.

On files, paths, and shortcuts

With the terminal, you access and work with files. A file is a container of data (remember from Data Handling: 0s and 1s).

  • Files have extensions (.txt, .csv, .pdf)
  • Files live inside directories (folders)
  • Every file has a unique location called a path

On files, paths, and shortcuts

To access files, their location must be given with paths. Paths describe where a file is located.

Absolute path:
  • starts from the root of the file system
  • example: C:/Users/Bilbo/Documents/TheRedBookofWestmarch.txt
Relative path:
  • starts from your current working directory
  • example: Documents/TheRedBookofWestmarch.txt

On files, paths, and shortcuts

From the terminal, you can use shortcuts instead of absolute paths.

Useful path shortcuts:

.    current directory

..    parent directory

~    your home directory (bash)

Examples:

  • file in the parent directory: ../file.txt
  • your Documents folder: ~/Documents

Main terminal commands

When you first open Terminal, you typically are placed in your home directory.

Main commands:
Description bash/macOS Command Prompt (Windows)
Check your current directory (print working directory) pwd cd
List the files in the current directory ls dir
Move into and out of the directory (change directory) cd <directory> cd <directory>
Create a directory (make directory) mkdir data mkdir data
Tips and additional commands:

Check the tips and experiment with additional commands in the self-study part (relevant for the exam).

Naming Conventions

Use Case Styles:

  • 🐍 snake_case (my_file_name.py)
  • 🐫 camelCase (myFileName.py)
  • 🍢 kebab-case (my-file-name.py)

Don’ts:

  • Do not use spaces in folder or file names! Never.
  • Avoid special characters (remember Data Handling and encoding nightmares).
  • Make sure to not switch styles within a project.

Naming Conventions: 🐍, 🐫 or 🍢

Following an established convention will not make you look like a complete novice. 😎🆒

On IDEs

What is an IDE?

An IDE (Integrated Development Environment) is a tool designed to help you write, run, and manage code efficiently.

Compared to a basic text editor, an IDE typically provides:

  • syntax highlighting
  • code completion and suggestions
  • error detection
  • integrated terminal
  • debugging tools
  • version control integration (e.g. Git)

These features reduce errors and make programming more structured and productive.

Examples: VSCode, Pycharm, RStudio, Posit

Visual Studio Code

Visual Studio Code (VS Code) is a lightweight but powerful code editor that behaves like a full IDE through extensions.

  • free and open source
  • available on Windows, macOS, and Linux
  • widely used in academia and industry
  • well suited for Python, R, and many other languages
  • very versatile and flexible!
  • integrated terminal
  • extensions for Git, notebooks, linters, and formatters
  • integrated Copilot!
  • syncs to all machines with a GitHub account


First setup (exercise session today)

  • Install VS Code
  • Install the “Data Science” profile
  • Install extensions
  • Run first Python script

Python

Why python?

Python is a good first (and second…) programming language.

  • easy to read and write
  • widely used in data science, economics, research, web development, automation, and AI
  • flexible enough for small scripts and large projects

Python or R?

It simply does not matter. If you stick around in data science long enough, you will eventually get in touch with both languages and, in turn, learn both. There is a huge overlap of what you can do with either of those languages. The point is, if you just start doing analytics using a programming language, both languages are guaranteed to carry you a long way. There is no way to tell for sure which one will be the more dominant language 10 years from now, or whether both will be around holding their ground the way they do now.” – Matthias Bannert, “Research Software Engineering”

Coming from R

If you know R (which you do…), Python will feel familiar, but not identical.

Key differences to keep in mind:

  • indentation is part of the language
  • indexing starts at 0
  • Python prefers explicit, readable code

Managing Python Projects

The Problem: Dependency Conflicts

In R, you mostly use a single global library. In Python, different projects need different python versions and package versions.


What happens without isolation?

Imagine you’re working on two projects:

  • Project A (old research): needs pandas version 1.5
  • Project B (new assignment): needs pandas version 2.0

If you install globally, updating for Project B breaks Project A!

A note on Python Interpreters

A Python interpreter is the program that reads and executes your Python code.


Your computer may have zero, one, or even multiple Python interpreters installed:

  • System Python: might come pre-installed with your operating system (Windows, macOS, some Linux)
  • User Python: Python you install yourself (e.g. from python.org, Anaconda, or via uv)
Each project can use a different interpreter with a different Python version (3.11, 3.12, etc.).

How R and Python differ

R:

  • Stronger standards for packages and package management (CRAN)
  • More backward compatibility
  • Global installation usually works

Python:

  • Many packages, many python versions and interpreters
  • “Wild West” ecosystem
  • Environments are essential

The Solution: Virtual Environments

Think of each project as having its own kitchen:

  • Each kitchen has its own tools, ingredients, and equipment
  • If one recipe needs an old oven and another needs a new one, they don’t conflict

In Python: A virtual environment is an isolated setup for each project with its own packages and Python version. This solves the conflict problem.

The Tool: uv

uv is a modern Python package manager that makes environments automatic and fast
  • manages virtual environments automatically
  • installs packages very fast
  • ensures reproducible setups
  • works consistently across systems

(Replaces pip, pip-tools, virtualenv, pip freeze or requirements.txt)


⚠️ Important: Never install packages globally with system Python! Always use environments.

Structure of a uv project

Each uv project has 3 key files

  • .python-version: python version to use
  • pyproject.toml: dependencies
  • uv.lock: exact versions of packages, automatically generated

uv generates a .venv/ folder containing the actual environment (don’t delete it!).

Getting started using uv

# Initialize a new project with its own environment
uv init my_project
cd my_project

# Add dependencies (creates/updates pyproject.toml)
uv add rich pandas

# When joining an existing project: install from lock file
uv sync

# Run code (automatically uses the project's venv)
uv run main.py

uv will store in each environment the version of the interpreter, the packages, and will “lock” each package version for the project in a lock file.

Until next time!

For next time

  • install git: we will start using version control from the next lecture.

Self study

A note on self-study

The self-study part contains additional materials that are difficult to cover in the main lecture. We expect you to go through these materials on your own time, and we will ask questions about them in the exam.

Additional useful commands to work with files in a terminal

Description bash/macOS Command Prompt (Windows)
Create an empty file touch hello.txt echo. > hello.txt
Delete a file rm hello.txt del hello.txt
Print file contents cat hello.txt type hello.txt
Edit a file nano hello.txt notepad hello.txt
Copy a file cp hello.txt hello_copy.txt copy hello.txt hello_copy.txt
Move/rename a file mv hello.txt goodbye.txt move hello.txt goodbye.txt

MacOS and Linux (bash, zsh) are unix systems. That’s why Mac and Linux use the same terminal commands (ls, cat, etc.), while Windows uses different ones (dir, type, etc.).

Tips when using the terminal

Some tips to work efficiently in the terminal:

  • Running cd without arguments takes you to ~
  • Use Tab for auto-completion of file and directory names
  • Use arrow keys to browse command history
  • All terminal commands work from wherever your shell is currently pointing, so you can navigate to the right directory and then run commands without worrying about paths
  • Look at Brad Traversy’s Common Terminal Commands

Experiment with these tips and additional commands in the terminal to get comfortable with it!

References and further reading

References: