46535.333333333336
Python, uv, and Code Editors
2026-08-27
Installation
Workspaces and Python Environment
Python Basics
Positron is a data science IDE for Python and R. It includes notebooks, variables, plots, terminals, and a project-based workflow.
Install the latest Visual C++ Redistributable.
Python is a general-purpose programming language widely used for statistics, data science, machine learning, automation, and reproducible research.
Tip
For this course, we will let uv manage Python versions, virtual environments, and package installation whenever possible.
uv is a fast Python package and project manager. It can install Python, create virtual environments, and install packages from a pyproject.toml file.
Visual Studio Code is a general-purpose code editor with strong Python support through extensions.
Recommended extensions:
VSCodium is an open-source build of VS Code with Microsoft telemetry disabled.
Recommended extensions:
Note
VSCodium uses the Open VSX extension registry by default, so extension names and availability can differ slightly from VS Code.
Installation
Workspaces and Python Environment
Python Basics
Workspaces allow you to create locations on your computer and set up a computing environment in one project folder.
A good workflow is:
pyproject.toml in that folder.uv sync once from that folder.uv run ... commands from that folder.Your course project folder should include a pyproject.toml.
A pyproject.toml file records project metadata and the Python packages required for the course.
Example structure:
Replace your pyproject.toml with the class toml file.
Open a terminal in the folder that contains pyproject.toml.
Then run:
This command will:
pyproject.toml..venv.uv.lock.Run Python inside the project environment:
Try importing a package:
Exit Python:
The course pyproject.toml includes packages for data analysis, visualization, statistical modeling, machine learning, and notebooks.
Core examples:
numpypandasmatplotlibplotninescipystatsmodelsscikit-learnjupyterNote
More packages may be added throughout the course if necessary.
You must import packages every new Python session.
Installation
Workspaces and Python Environment
Python Basics
Python can evaluate expressions in the console or in a code cell.
Try the following:
46535.333333333336
Python functions perform tasks on specific values.
Evaluate the following values in Python:
3.6739403974420594e-16
int, floatstrboolNone, np.nan, or pd.NAEvaluate the following code:
NoneType
In Python, an object contains data and behavior. Common data objects include lists, arrays, dictionaries, and data frames.
Run this code and print the objects:
array([[ 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20]])
Data frames can be thought of as Python’s version of a data set.
Play around with a small data frame:
| mpg | cyl | gear | |
|---|---|---|---|
| 0 | 21.0 | 6 | 4 |
| 1 | 21.0 | 6 | 4 |
| 2 | 22.8 | 4 | 4 |
| 3 | 21.4 | 6 | 3 |
| 4 | 18.7 | 8 | 3 |
A list stores multiple Python objects in order. The elements can be different types.
Try playing with this Python object:
[ mpg cyl gear
0 21.0 6 4
1 21.0 6 4
2 22.8 4 4
3 21.4 6 3
4 18.7 8 3,
[0, 0, 0, 0],
array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])]
You can compare two numbers or objects. The result is a logical output: True or False.
| Operator | Description |
|---|---|
> |
Greater Than |
< |
Less Than |
>= |
Greater than or equal |
<= |
Less than or equal |
== |
Equals |
!= |
Not Equals |
A dictionary stores values by name.
[0, 0, 0, 0]