Module 2: Basic Python

Class ressources

  • Lecture on python basics
  • Exercises on python basics

    Organisation

    In class: 15 min lecture + 25 minutes exercises + 5 minutes review:

  • Hour 1: concepts 1, 2, 3
  • Hour 2: concepts 4, 5

Concepts

  1. Assignment and scalar types
  2. Strings
  3. Lists, tuples and sets
  4. Dictionaries
  5. Tracebacks
  6. Introduction to Pixi & executing .py files from the shell
  7. Executing .py files in VS Code
  8. Executing notebooks in vscode

Learning objectives

After this lesson, you should be able to:

  1. Assignment and scalar types:
    • List several built-in scalar types in Python
    • Assign and manipulate scalar variables in Python
    • Convert variables between different types
  2. Strings

  3. Lists, tuples and sets:

  4. Dictionaries:
    • Assign flat and nested dictionaries in Python
    • Access elements in flat and nested dictionaries
    • Update or insert elements in dictionaries
    • Explain some benefits of labeled data structures
  5. Tracebacks:
    • Read and interpret tracebacks
    • Identify common errors in Python code
    • Use tracebacks to debug code