A curated index of all the guides, references, and other writeups for the CompCiv class.


I’ll be adding lessons and guides here, on a regular basis, as I polish them up. The assignments listing can be found at: /assignments

Python fundamentals

Guides to Python fundamental concepts
For-loop fundamentals
How to repeatedly execute code, over and over, for a specified number of times.
Conditional branching fundamentals
How to use if/else statements to create branches of code in your program that may or may not actually execute.
Opening files and reading from files
How to opening files and read from files and avoid annoying mistakes when reading files
Opening files and writing to files
How to open files and write to files and avoid catastrophic mistakes when writing to files.
Python Objects and Data Structures
Everything in Python is an object. Here are the built in objects and data structures, including an overview of their most commonly-used methods and behaviors.
Text as String Objects
How to represent and operate on text values using the Python str object.
Lists, mutability, and in-place methods
Lists are ordered collections of other objects. And lists are mutable.
The Immutable Tuple
Tuples are lists that never change.
Using dictionaries to store data as key-value pairs
The dictionary stores objects as key-value pairs and can be used to represent complex real-world data.
Function fundamentals in Python
Think of functions as shortcuts for executing blocks of code.
Sorting Python collections with the sorted method
Sorting a list of items is not as simple as it seems. But it is also far more important than it seems.

Python How-Tos

Common tasks in Python, both using the standard libraries and popular third-party libraries
Downloading files with the Requests library
Using the Requests library for the 95% of the kinds of files that we want to download.
Creating URL query strings in Python
How to make Python do the tedious work of creating URL query strings.

Development Environment and Operating System Tasks

A collection of references about setting up and moving around your programming environment.
Conventions for depicting system shell and Python commands
A reference for the conventions I use to differentiate between system shell commands, Python code, and the interactive Python prompt.
Using no-frills Git and Github from the command-line
A guide to using Git and Github for the simple things: maintaining, backing up, and occasionally publishing our work online.

Real-world practice

Practice programming concepts on real-world data and scenarios.
Project Example: Show Me Nearest Earthquakes
A step-by-step process of creating a project that downloads earthquake data, geocodes a user's location, and displays the nearest locations.
Say Hello to the User
Writing a Python script that responds to a user is as easy as using the input() function
Making and packaging a fake (for now) geocode() function
We might not know how to write a geocoder yet, but we can at least fake it with some fake data and then package it in the Python way.
Documenting our fake geocode() function with a docstring
By adding a "docstring" to the beginning of our functions, we can create a human-readable piece of text that describes what our function actually does.
Parsing the Mapzen response data before actually calling the API
Before we make the geocode() function actually talk to Mapzen, let's just focus on a pre-fetched response and extracting the data from it.
Contacting the Mapzen API and geocoding a real location
After all that work to prepare for the response from the Mapzen API, we just have to call the correct endpoint and pass along the location.
Visualizing Geopolitical Sensitivities with the Google Static Maps API
APIs are complicated because geopolitical disputes are complicated
Tackling the FizzBuzz test
Solve this infamously difficult programming interview question with for-loops and conditional branching
Extracting and Reading Shakespeare
A walkthrough of modules, file system operations, and Shakespeare.
How to create a directory idempotently with makedirs()
A quick tutorial on using the os.makedirs() function to create directories
Downloading and saving the Shakespeare zip with requests
How to download and save a file to disk. And how to properly resolve a file's full path, including its directory.
Unzipping the Shakespeare zipfile with the shutil module
Unpacking archives exactly where we want with the shutil.unpack_archive() function
Count the lines of Shakespeare's Hamlet
To count all the lines in a file, we have to read every line in the file.
Print the final 5 lines of Romeo and Juliet
In order to read just the final 5 lines about these star-crossed lovers, we have to first read the entire tragedy.
Print the final 5 lines of each of Shakespeare's tragedies
Using a for-loop inside another for-loop to experience a whole lot of tragedy.
Counting the non-blank-lines in Shakespeare's tragedies
A simple text-processing and analysis exercise, using everything we've learned so far about file paths, for-loops, and conditional branching.