Change the future

Wednesday 9 a.m.–12:20 p.m.

Python for Programmers: A Project-Based Tutorial

Alexandra Strong, Katharine Jarmul, Christine Cheung

Audience level:
Novice
Category:
Core Python (Language, Stdlib)

Description

Are you a Python-curious programmer? Learn by writing your first project! You'll build a complete quiz creation web application. We will cover topics from data structures and classes, to debugging and testing.

Before the day of the workshop, you will need to have Python 2.7, CherryPy, IPython, and Jinja2 installed. Alternatively, you may arrive at the venue an hour early to receive assistance.

Abstract

This is a guided tutorial for programmers who have not used Python before. You will build a Python web application from scratch. Students will receive the full project source code as well as tutorial slides.

Course topics (in order that they will be presented):

Topic 1: Intro to IPython interpreter

  • How to run it
  • Discussion of what version of Python you should be using

Topic 2: Working with ints and strings (in interpreter)

  • Cover useful methods

Topic 3: Data Structures and their caveats (in interpreter)

  • tuples, lists, dictionaries
  • Cover useful methods of data structures
  • Mutable vs immutable
  • The usefulness of hashable data structures

Topic 4: List comprehensions

  • When to use, when NOT to use

Topic 5: Whitespace awareness

  • Debunking whitespace myths - “defending whitespace”
    • http://www.secnetix.de/olli/Python/block_indentation.hawk

Topic 6: Resources for devs

  • Python docs, IRC, Community
  • GitHub, StackOverflow

Topic 7: Functions (begin working with Python files)

  • Focus on writing DRY code

Topic 8: Boolean logic in python

  • Worksheets
  • Brief discussion about boolean logic

Topic 9: Control structures (continue working in Python files)

  • if, else, for, while, do
  • Infinite loops

Topic 10: Exceptions

  • Discuss the stdlib exception classes and what they mean
  • Write custom exception class

Topic 11: Program layout

  • Discuss module discovery
  • How Python uses init.py

Topic 12: Useful functionality in the stdlib

  • datetime, hashlib, json, math, urllib2, user input

Topic 13: Classes

  • Cover the basics
    • The init method
    • Inheritance
    • Class variables and methods
  • Have them write a simple class for the project

Topic 14: Testing

  • How to use the unittest module

Topic 15: Debugging

  • How to debug your code when something goes wrong