2025-06-19
Theme: Literate programming
This week, you’ll:
‘Literate programming’ is a blending of executable code and prose. It promotes better communication and understanding by making code more human readable.
Programming is best regarded as the process of creating works of literature, which are meant to be read.
Quarto is an open-source publishing system developed by Posit, the creators of RStudio. It uses .qmd documents to combine code and text in static and interactive outputs like HTML, Word documents, slides and dashboards.
There are two ways to install Quarto:
Download the Quarto command line interface (CLI) from the website.
Or open the Terminal and run:
python3 -m venv quarto # create a virtual environment
quarto\Scripts\activate.bat # activate the environment
pip install quarto-cli # download and installThen install the Quarto extension in VS Code.
.qmd file{python}---
title: "Gapminder"
format:
html:
self-contained: true
execute:
echo: false
jupyter: python3
---
Data on life expectancy at birth, GDP per capita and total population are provided for 142 countries between 1952 and 2007 courtesy of [gapminder](https://www.gapminder.org/data/).
```{python}
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
gapminder = pd.read_csv("data/gapminder.csv").query('year==2007')
fig, ax = plt.subplots(figsize = (7, 5))
sns.scatterplot(data=gapminder, x='gdpPercap', y='lifeExp', hue='continent')
ax.set_xlabel('GDP per capita', size=12 )
ax.set_ylabel('Life expectancy', size=12)
ax.set_title('Relationship between life expectancy and income, 2007', size=14)