Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Latest commit

 

History

History
56 lines (37 loc) · 5.59 KB

frontmatter.md

File metadata and controls

56 lines (37 loc) · 5.59 KB

Introduction to Python

Abstract

Python is a general-purpose programming language suitable for a wide variety of tasks in the digital humanities. Learning Python fundamentals is a gateway to analyzing data, creating visualizations, composing interactive websites, scraping the internet, and engaging in the distant reading of texts. This workshop first introduces participants to core programming concepts such as data types, variables, and functions. Participants will then learn about basic control flow by writing small programs with loops and conditional statements. They will also learn to problem solve, and practice searching for answers and debugging scripts. The workshop wraps up by exposing participants to intermediate tools for further exploration.

Learning Objectives

  • Understand what Python is and, in general terms, what it can do.
  • Run Python programs, both by interacting directly with the interpreter and by preparing and running scripts.
  • Distinguish among five core data types—integers, floats, strings, booleans, and lists.
  • Become familiar with core programming concepts, including variables, loops, and conditionals.
  • Engage with error output and use the internet and documentation to independently research language features.
  • Learn how to find and import code from external sources to solve more complex problems.

Estimated time

3-4 hours

Prerequisites

  • Introduction to the Command Line (required) This workshop makes reference to concepts from the Command Line workshop, and having basic knowledge about how to use the command line will be central for anyone who wants to learn about programming with Python.
  • Installing Anaconda (recommended) You can use any installation of Python (but make sure it is of version 3) but for our purposes, Anaconda will provide everything necessary for all the workshops that are part of the DHRI curriculum.

Contexts

Cheat Sheets

Pre-reading suggestions

Projects that use these skills

  • Built by former Digital Fellow Patrick Smyth, The NEH Impact Index makes visible the distribution of funds by National Endowment for the Humanities across the United States. The website uses python to map projects, communities, and cultural institutions who have received NEH support. You can check out the code on Github.
  • Mapping Arts NYC, created in 2019 by the Graduate Center's Data for Public Good fellows, "is a project that explores the geography and representation of arts and culture in New York City over time." It includes a number of Python scripts written to clean and make sense of all the data.
  • Python programmers build and maintain various "libraries," or collections of python code, that can be re-purposed toward custom projects. You might check out the Scrapy library for web scraping, the NumPy library for numerical computing, or the pandas library for data analysis and manipulation. Check out the individual websites to help you think about the data that you want to work with.

Ethical Considerations

  • Python works by reducing data to portable units and presenting them in a way that prioritizes readability. These units are known as "data types" and include strings (words/letters), integers (numbers), booleans (true or false statements), and lists (groups of strings). The python grammar, which dictates how python statements ought to be ordered, values simplicity, efficiency, and concision. You can read more about python values at the Zen of Python.
  • As we learn about the python data types and grammar, keep in mind that working within any digital format requires making seemingly neutral choices that carry ethical consequences. When using python, be aware of the ways the ways that data is transformed into computable form. What choices are you making about your data? What is being included, and what is left out? What are reductions and assumptions necessary to encode your data? If you are more interested in thinking further about data types and our choices in relation to data, you should have a look at our Data Literacies workshop.

Acknowledgements