← All weeks and tools

Week 1: code along

Cultural Data Analysis · Lecture 1: Data Analysis with Python

Interactive tools from this lecture: CPU simulator · Loops in four languages

This week's workshop: Python

Today has three parts. In each part, type the code examples from the slides yourself as we go: keep this page open next to a blank Python Tutor (choose Python 3). One exercise, NumPy, runs in Google Colab instead. The slides show the number of each exercise in their top corner.

At the end of each part, a Let's try slide sends you to the matching section of the lecture notebook: there you run the same ideas in Colab and go a bit further. Open it once now and choose File → Save a copy in Drive, so that your changes are kept. Each part below ends with a link to its section.

There are two kinds of exercise:

Then check your result against the expected output, and try the follow-up under Then.

Contents


    Python Tutor runs plain Python only, so it cannot import NumPy or pandas. Use Google Colab for those. Python Tutor: pythontutor.com · Computer Programming Spectrum