Skip to content

Latest commit

 

History

13 Commits

Folders and files

Repository files navigation

NC State University Libraries logo

Introduction to Programming with Python

NC State Libraries Workshops Data Science Services Get Data Help

A hands-on introduction to Python from NC State University Libraries' Data Science Services, first taught at the Data Science Training Intensive. Attendees install Python and JupyterLab on their own laptop with uv (or conda, if they already use it), then work there: variables, data types, lists and dictionaries, operators, if, for, methods, and a function of their own. Google Colab is the backup when an install gets stuck.

Workshop site: https://ncsu-libraries.github.io/dsti-python/

The notebooks

Notebook Open it
Learner: blank code cells you fill in with the instructor Open the learner notebook in Colab
Filled: every exercise answered, to check your work Open the filled notebook in Colab

To work on your laptop, follow the site's Setup page: it downloads the notebook and opens it in JupyterLab. In Colab, click Copy to Drive so your changes are saved to your own Google Drive.

The notebooks condense the Basics and Loops and Functions workshops from Getting Started with Python. The full workshops cover everything skipped here: dates and times, type conversion, while loops, and reading and writing files.

What's here

Path What it is
notebooks/ The session's learner and filled notebooks, generated by tools/build_notebooks.py, and the follow-along activities' notebooks, generated by tools/build_activities.py
data/ The activities' data files, served from the site for download
site/ The Quarto website: start page, setup guide, cheat sheet, and the slide deck (site/slides/)
tools/ The notebook builders (build_notebooks.py, build_activities.py with one module per activity in tools/activities/), atus_data.py for the time-use data, the post-render step that copies notebooks and data into the site, a link checker, a screenshot script, and the setup video's recorder (record-tour.mjs, tour/)

Build it locally

You need Quarto 1.10 or later. RStudio ships one at /Applications/RStudio.app/Contents/Resources/app/quarto/bin/quarto.

quarto render site                   # builds site/_site, including the deck; post-render copies notebooks/ into it
quarto preview site                  # or serve it locally while editing
python3 tools/check_links.py [--web] # checks every link and image in site/_site; --web also requests external URLs

Rebuild the notebooks

The notebooks are built from a pinned commit (9b288fa) of getting-started-with-python. With that repository checked out locally:

python3 tools/build_notebooks.py --src ~/Desktop/getting-started-with-python

Change the notebooks by editing the manifest in tools/build_notebooks.py and running it again. Hand edits to the .ipynb files are overwritten on the next build.

The activity notebooks come from one module per activity in tools/activities/, and their data from data/:

python3 tools/build_activities.py      # regenerate the activity notebooks; --check fails if any is stale
python3 tools/atus_data.py             # rebuild data/atus_*.csv from the DSTI team's shared drive
node tools/record-tour.mjs             # re-record the Setup page's video (needs Google Chrome and ffmpeg)

Publishing

Pushing to main runs .github/workflows/deploy-pages.yml, which renders the site and deploys it to GitHub Pages. Set Settings → Pages → Source to GitHub Actions before the first push, or the first deploy fails; if it did, re-run the workflow from the Actions tab. Changes to notebooks/ redeploy too, because the site serves the notebooks for download. The Colab links work once the repository is public on GitHub.

If the site moves to a different GitHub owner or repo name, search for ncsu-libraries.github.io and NCSU-Libraries/dsti-python and change both, then point the go link in site/_variables.yml at the new address and regenerate its QR code (site/images/qr-session.svg).

License

Content is licensed CC BY 4.0 and code is MIT. The notebooks adapt material from Getting Started with Python (CC BY 4.0) by Alp Tezbasaran, with credit to Selene R. Schmittling.

The time-use activity's data (data/atus_*.csv) is an extract of the American Time Use Survey (U.S. Bureau of Labor Statistics), via ICPSR study 36268, sampled and prepared by the Data Science Training Intensive team.

The café activity's data (data/cafe_sales.csv) is synthetic, from the Libraries' Agentic Coding with Claude workshop (CC BY 4.0).

Contributors

Languages