Welcome to

Introduction to Scientific Python! 🎉

Intro to Scientific Python

Module 01: Introduction to Git and Python

September 14, 2026

Intro to Scientific Python

Content covered:

  1. Class Overview
  2. Getting the Course Materials with Git
  3. Setting up Your Python Environment
  4. What is Python
Intro to Scientific Python

By the end of this class, you will be able to:

  • Launch and navigate a command-line interface
  • Clone a git repository and navigate the resulting directory
  • Use the interactive Python shell (ipython)
  • Identify and use core Python data types (str, int, float, list, dict)
  • Call built-in functions and import libraries
Intro to Scientific Python

1. Class Overview

Intro to Scientific Python

Instructor Introductions

Intro to Scientific Python

Teon Brooks, Ph.D

Academic Background

  • Ph.D in Cognition and Perception @ New York University
  • Postdoc in Neuroinformatics @ Stanford University

Professional Background

  • Data Scientist @ Mozilla (2017-2024)
  • Co-Founder @ Gotham Data Clinic (2019-Present)
  • Neural Data Scientist @ Meta FAIR (2025-Present)

Interests

Contact: brookst3@mskcc.org

Intro to Scientific Python

Your TA: Tejiri (Tay-JEE-Ree) Agbamu

  • 5th-year GSK student
  • PI: Jian Carrot-Zhang and Nikolaus Schultz (Department of Epidemiology & Biostatistics)
  • Research interests: Cancer genomics, computational pathology, and cancer disparities
  • Thesis work: Interplay of smoking exposure, clinical attributes, and genomics; Ancestral clinico-determinants of clinical response in breast cancer
  • Hobbies: reading, weightlifting, watching football/basketball, manic walking/biking
  • Favorite programming language: Python or R (depends on the day)
  • Contact me: agbamut@mskcc.org or Slack for the fastest response
Intro to Scientific Python

Ice Breaker

  • Who are you?
  • What are you studying?
  • What is current programming/coding skill level?
  • What would you like to get out of the class?
Intro to Scientific Python

The Goals of this Course

  • Build a foundation in Python
  • Understand control flow and scripting
  • Introduction to the Scientific Python stack
  • Create scripts and reports for data analysis
Intro to Scientific Python

Anatomy of the Class

  • The first hour is lecture and active learning, woven together
  • The last 15 minutes is an in-class problem set, worked on in groups

Programming is a team sport. Even at companies, if someone is writing, then someone is reviewing.

Intro to Scientific Python

Syllabus Review

Intro to Scientific Python

Course Structure

  • 10 sessions, 1:30pm - 3:00pm, including a final project session
  • Graded pass/fail: participation, weekly homework, final project
  • Teaching Fellows are in every session to help out

Generative AI Policy

The first three weeks (Modules 1-6) are foundational: git and core Python, without an agentic programming tool (Claude Code, Copilot, Cursor, etc). We'll dedicate a whole class to using one later, but working effectively with one requires
that you first understand the fundamentals of programming.

Intro to Scientific Python

Course Schedule, at a Glance

Week Modules Topics
1 1-2 Intro to Git and Python; Notebooks, Control Flow, Functions
2 3-4 NumPy; Matplotlib
3 5-6 Pandas; Pandas & Seaborn
4 7-8 SciPy; statsmodels & scikit-learn
5 9-10 Agentic Programming & Advanced Topic; Final Project Presentation

A weekly assignment is given each Wednesday, due the following Wednesday.

Intro to Scientific Python

2. Getting the Course Materials with Git

Intro to Scientific Python

Why Git?

Git is a distributed version control software that lets you download, share, and collaborate on a project.

git is the command line tool that lets you save your work, manage different versions of it, and contribute it.

We'll go into git in more depth across the first four modules. Today, we will use it to get the course materials onto your machine.

Intro to Scientific Python

Cloning the Lecture Notes

First, check whether you have git installed:

which git

If that comes back empty, install git from git-scm.com.

A common task you will do with git is clone a repository. Cloning a repository creates a copy of the repository on your local device.

Intro to Scientific Python

Cloning the Lecture Notes, cont.

First, let's create and move into our workspace folder for this class:

mkdir ~/workspace
cd ~/workspace

Now, let's clone our first repo:

git clone https://github.com/datalus-dev/gsk-intro-scientific-python-course.git
Intro to Scientific Python
cd gsk-intro-scientific-python-course
ls

This is now your local copy of the course materials: lecture notes, data, and in the future, the homework assignments.

We'll pull updates to this repo throughout the course.

Intro to Scientific Python

git status

git status

Tells you what's changed in your local copy since the last commit.

Intro to Scientific Python

Remotes

Remotes refer to the remote repository that we are working with. For the repo we just cloned, we'll be working with the default remote, known as origin.

git remote -v

This command with the argument -v gives us a verbose message of the remotes we have. It will show the name of the remote and where it is stored.

Intro to Scientific Python

3. Setting up Your Python Environment

Intro to Scientific Python

Setup

  • Setting up your Python environment on your local machine
  • Setting up project and file organization
Intro to Scientific Python

The Tech Stack

This class is built on the following Tech Stack:

conda - We will be primarily using conda to set up the environment on our computers

pip - pip is the Python installation manager.

conda and pip are both package management systems. pip is specific to Python package management whereas conda is a more general manager that can also create environments (isolated installation environments).

Intro to Scientific Python

The Tech Stack, cont.

marp - Presentation package to create slides using Markdown.

JupyterLite - A full Python console, running right in your browser. We'll use it throughout the semester for live demos.

Intro to Scientific Python

Terminal (ipython)

A more comfortable place to run Python interactively than the plain python shell — syntax highlighting, tab completion, and better history.

Intro to Scientific Python

Jupyter Notebooks

A notebook interface for writing and running Python in cells, mixing code, output, and notes. JupyterLite gives us this experience right in the browser, no install needed.

Intro to Scientific Python

Try it live

print("Hello, JupyterLite!")
Intro to Scientific Python

Checking Your Installation

If you followed the pre-class setup, you should have miniforge (conda) installed. Check with:

conda --version
python --version
conda env list
Intro to Scientific Python

Setting up This Course's Environment

This course's environment is described in environment.yml, in the root of the course repo:

conda env create -f environment.yml
conda activate gsk
Intro to Scientific Python

What is the Command Line?

A text interface for talking directly to your computer — instead of clicking, you type commands.

pwd    # print working directory: where am I?
ls     # list: what's in this directory?
cd ..  # change directory: move up one level

What is (base) at the beginning of your terminal line, and why is it there?

What is an environment?

Intro to Scientific Python

Workspace Organization

Organizing your projects and packages will save you from so many headaches in the future.

This is crucial for reproducible workflows and for writing clean code.

Intro to Scientific Python

My Workspace*

/Users/teonbrooks/workspace
├── _websites
├── mne-python
├── gsk-intro-scientific-python-course
├── OcularLDT-project
├── passports.social
└── phd-thesis

*condensed for brevity
*made with tree

Intro to Scientific Python

Workspace

You should have a folder to store all of your projects.
I call mine workspace.

Each project should have a descriptive yet succinct title.

Intro to Scientific Python

My Tech Stack

Intro to Scientific Python

Quick Break

Intro to Scientific Python

4. What is Python

Intro to Scientific Python

Discussion

Q: What is Python?

Q: What are some of its use cases?

Q: What are you interested in doing with Python?

Intro to Scientific Python

Python

A high-level scripting language that makes it easier to interact and control lower-level processes.

Intro to Scientific Python

Python is great because it introduces a new level of interactivity with programming.

Instead of the "write your program and hope it executes properly" (compiled language), Python lets you interact with your data in the shell (scripting language).

Well thought out language, allowing to write very readable and well structured code: we "code what we think". (Scientific Python lectures 1.1.1)

Intro to Scientific Python

A little Motivation

So why use Python?

Python works well with lower-level languages like C because Python is written in C.

Software engineers who want to write really performant code will write in a system programming language like C or Rust, but they will write bindings to a higher-level language like Python because it's easier to use.

Here's a link to a documentary about the origins of Python:
youtu.be/GfH4QL4VqJ0

Intro to Scientific Python

Scientific Python

  • Most of the scientific computing libraries are written in Python.

https://scientific-python.org/about/

Intro to Scientific Python

Let's checkout

the terminal and ipython

Intro to Scientific Python

Launching an Interactive Shell

Launch an interactive Python shell:

python

or, for a nicer experience:

ipython
Intro to Scientific Python

Some Common Data Types

Numeric types - integers, floats

Boolean types - bool

Text sequence - strings

Sequence types - lists, tuple, range

Set types - sets

Mapping types - dict

Intro to Scientific Python

Try it live

type(1)
type(1.0)
type(True)
Intro to Scientific Python

Try it live, cont.

type("hello")
type([1, 2, 3])
Intro to Scientific Python

Try it live, cont.

type((1, 2, 3))
type({1, 2, 3})
type({"a": 1})
type(range(5))
Intro to Scientific Python

All the Built-in Data Types in Python

https://docs.python.org/3/library/stdtypes.html

Intro to Scientific Python

Data type, cont.

Some data types are mutable, meaning their values can be changed after they've been instantiated

e.g. lists, dictionaries

Some data types are immutable, cannot be changed or modified after instantiated
e.g. sets, tuples

Intro to Scientific Python

Strings

Strings store sequences of characters.

Objects can have methods — functions stored on them. Access an object's methods with a period after its name, then hit tab to see what's available.

Use a pair of '' or "" to make a string. If your string needs to contain one type of quote, use the other to wrap it.

Intro to Scientific Python

Strings, cont.

Some common string methods:

  • join: combine an iterable of strings into one
  • split: divide a string into a list
  • upper / lower: convert to all uppercase / lowercase
Intro to Scientific Python

Try it live

name = "Teon Brooks"
name.upper()
name.lower()
name.split(" ")
Intro to Scientific Python

Lists

Lists are containers — they can hold other data types, and they're iterable, meaning you can loop over them.

Some common methods:

  • append: add an item to the end of a list
  • extend: combine another list or iterable into it
  • index: return the position of a value
Intro to Scientific Python

Lists, cont.

Python is zero-indexed — the first item in a list is index 0.

numbers = [1, 2, 3, 4, 5]
numbers[0]

Index -1 has a special meaning: it returns the last element.

Intro to Scientific Python

Lists, cont. — Slicing

Indexing a range of values is called slicing — the result is a list.

numbers[2:4]

Return every second item:

numbers[::2]

The general form is list[start:stop:step].

Intro to Scientific Python

Try it live

numbers = [1, 2, 3, 4, 5]
numbers[0]
numbers[-1]
Intro to Scientific Python

Try it live, cont.

numbers[2:4]
numbers[::2]
Intro to Scientific Python

Strings, revisited

.join takes an iterable and concatenates it with the given string:

"-".join(["apples", "oranges", "strawberries"])

.split does the reverse — it breaks a string apart into a list:

"apples-oranges-strawberries".split("-")
Intro to Scientific Python

Dictionaries

Dictionaries are also containers — a mapping type, storing content in key/value pairs (also called entries).

my_dict = {
    "pet": "cat",
    "animals": ["cats", "dogs", "birds"],
}

You can also build one with the dict() constructor, though keys built that way can't contain symbols like - or *.

Intro to Scientific Python

Dictionaries, cont.

Retrieve a value using its key:

my_dict["pet"]

.get() also retrieves a value, with a default for when the key doesn't exist:

my_dict.get("missing", "not found")

Q: What happens if you index with [] using a key that isn't in the dictionary?

Intro to Scientific Python

Try it live

my_dict = {"pet": "cat", "animals": ["cats", "dogs", "birds"]}
my_dict["pet"]
my_dict.get("missing", "not found")
Intro to Scientific Python

Checking an Object's Type

To check the type of an object, here are a couple of built-in convenience functions:

  • type(obj): returns the type of a given object
  • isinstance(obj, list): checks whether obj is an instance of a given type
Intro to Scientific Python

Try it live

type([1, 2, 3])
isinstance([1, 2, 3], list)
Intro to Scientific Python

Discussion

Q: What's the difference between 1 and 1.0?

Q: What happens when you add them together?

Intro to Scientific Python

Try it live

1 + 1.0
type(1 + 1.0)
Intro to Scientific Python

Assignment

You can assign a value to a variable using the assignment operator =.

x = 5
x
x + 10
Intro to Scientific Python

Built-in Functions

Python ships with functions ready to use, no import needed:

  • len(obj): length of a sequence
  • max(...) / min(...): largest / smallest value
  • sum(obj): total of a sequence of numbers
  • abs(x): absolute value
  • any(...) / all(...): True if any / all elements are truthy
  • bool(x): convert to True/False
Intro to Scientific Python

Try it live

len([1, 2, 3])
max(4, 7, 2)
min(4, 7, 2)
sum([1, 2, 3, 4])
Intro to Scientific Python

Try it live, cont.

abs(-5)
any([False, False, True])
all([True, True, False])
Intro to Scientific Python

Importing Libraries

Not everything is built in — the standard library and third-party packages add more with import:

import math
Intro to Scientific Python

Try it live

import math
math.sqrt(16)
math.pi
Intro to Scientific Python

Practice (10 min)

Intro to Scientific Python

In Groups...

Let's work on these questions:

  1. Assign your name, age, and favorite number to three variables of different types (str, int, float)
  2. Use type() to confirm each one
  3. Put your group's ages into a list. Use len(), max(), min(), and sum() to answer: how many people are in your group? What's the average age?
  4. import math and use it to compute something — e.g. math.sqrt() of your group's total age
Intro to Scientific Python

Your Workspace

Intro to Scientific Python

That's it for today!

Next class: Module 02 — Jupyter Notebooks, Control Flow, and Functions.

Intro to Scientific Python

NOTE: the JupyterLite consoles below point at the deployed GitHub Pages site (https://datalus-dev.github.io/gsk-intro-scientific-python-course/jupyterlite/), built and published automatically by .github/workflows/deploy-jupyterlite.yml on every push to main. To test against a local build instead, run `jupyter lite build --output-dir _build/jupyterlite --contents notebooks`, serve it, and swap the `src` host accordingly.