Module 1 - Foundations of Python Coding¶
This module introduces the essential concepts of Python programming and the foundational practices needed for scientific software development. Participants learn how to set up a working environment, write clear Python code, use notebooks and scripts, process data, and organize small projects in a way that can grow later.
Learning outcomes¶
By the end of this module, participants will be able to:
- Set up a working Python environment using Miniforge3 and VS Code.
- Understand and use Python syntax, data structures, and control flow.
- Write and execute simple scripts and notebooks.
- Use core scientific libraries such as NumPy, pandas, and matplotlib.
- Follow basic best practices for readability, reproducibility, and structure.
- Apply introductory object-oriented programming concepts.
- Manage dependencies in virtual environments with
conda,venv, andpip.
Study pages¶
Use the pages linked below as the student-facing handbook for this module:
- Module 1 study guide
- Getting ready: Python environment and tools
- Python basics
- Control flow and data structures
- Working with files and data
- Code quality and good practices
- Introduction to object-oriented programming
- Project organization for small Python projects
Sections and timing¶
- Quick welcoming to the course and module (15min)
- Setting up the Python and Development Environment (1h-1h15min)
- Installing VS Code, Python via Miniforge3, and checking GitHub accounts
- Configuring VS Code for Python development
- Creating and managing virtual environments (
conda,venv) - Jupyter Notebook introduction
- (Optional) Quiz
- Introduction to Python (45min)
- What is Python?
- The interactive Python terminal
- Variables and naming conventions
- Basic data types: string, integer, float, boolean, complex
- Expressions and operators
- (Optional) Quiz
- Core syntax and control flow (1h30min)
- Functions
- Conditional statements (
if/elif/else) - Data structures: lists, tuples, dictionaries, sets
- Iteration (
forandwhileloops) - List comprehensions
- Recursion
- Error and exception handling
- (Optional) Quiz
- Working with Files and Data (1h30min)
- Basic input/output (I/O) file operations: text, CSV, and JSON
- Numerical arrays and vectorized operations (
numpy) - Visualizing data (
matplotlib) - Structured data handling (
pandas) - Managing file paths (
os,pathlib) - (Optional) Numerical methods in Python (
scipy) - (Optional) Quiz
- Code Quality (45min)
- Reproducible research code
- Python style conventions (PEP 8)
- Writing clear docstrings and comments
- Introduction to Python typing and style checks (
mypy,ruff) - Basic logging and informative error messages
- Introduction to testing
- (Optional) Quiz
- Introduction to Object-Oriented Programming (OOP) (1h30min)
- Classes, attributes, and methods
- Abstraction
- Naming conventions and design
- SOLID principles vs. functional programming
- (Optional) Quiz
- Teaser to Project Organization (30min)
- Recommended folder structure
- Introduction to templates
- Naming and modularization
- (Optional) Quiz
Participants' projects¶
After the last session, we will organize an additional 2-hour session for all participants. The goal is to give everyone uninterrupted time to work on their own projects with support from experts and peers.