header image
Check this page for updates on upcoming classes, our learning goals, and the lesson modules we'll use to get there.

CIT-129: Python 2 Session Guides

Course Schedule and Lesson Guides

Please treat each week's guide as gold--it is your path through this course, week-by-week. If you have any questions, please call the technologyrediscovery.net shop at 412.894.3020.

I can also receive emails at edarsow@ccac.edu but programming questions can most effectively be answered over the phone or during office hours.


Current Week

Week 12: Tuesday, 24 April - Monday, 30 April

Our goal is to embrace exposure to how python can seamlessly interact with database systems of all kinds. Many, many python applications involve retrieval of data from or insertion into a database application. To do so, we must use a database driver that connects Python with the particular application that manages the database.

Python has libraries for connecting to nearly any major database out there, and many smaller, lesser known ones.

check_circleLearning Objectives

  • Define a database in terms of spreadsheet tables and data duplication
  • Draw a diagram of a basic database structure, the Python connector, and the interpreted Python code
  • Write Python code which connects to a MySQL database, extracts information from existing tables, and inserts information into existing tables
  • High-level objective: Call an API in Python, extract information from the API Response, and store some portion of that retrieved data in the database itself.

languageResources and Documentation

listLesson Sequence

  1. Install MySQL Database: We'll be using a free and open source database called MySQL, which is available for all major platforms. You'll need to install the MySQL community edition using guidelines on the MySQL page appropriate for your platform (OS).
  2. Install a database GUI: The database tool itself doesn't have a graphic interface--it's only a "back end" program. There are many front-end GUIs that can interact with a working MySQL database. The most popular is MySQL WorkBench, which is also free and open source. You should consider installing MySQL Workbench unless you are a whiz at SQL from the command line.
  3. Try inserting sample data into your MySQL database using this table set and instructions available via the MySQL folks. Remember: we're making the empty tables first, and then loading a few million rows of data into those tables.

editMid-week ToDOs

cakeProducts to Produce

  • Upload your a python files related to your API calls to your GitHub account. I suggest creating a subdirectory in your git repository called "api_practice" or something like that. Once uploaded, make sure the files are publicly accessible, and then complete an entry in this code tracking spreadsheet.

Past weekly session guides

Week 11: Tuesday, 17 April - Monday, 23 April

Many websites

check_circleLearning Objectives

  • Explain the essential structure of HTML pages and how they store structured information. Write a basic HTML page about a life interest.
  • Employ the urllib and BeautifulSoup libraries to pull down an HTML page and find a particular element, and extract the data in that element.
  • Systematically store the result of a screen scraping endeavor into a text file that can be shared and used as inputs by other programs or tools.

languageResources

listLesson Sequence

  1. Review API call programs from last week. Fill Caroline in on the magic. Troubleshoot programs as needed
  2. Run through screen scraping example on GoodReads.com. Learn how to use urllib and BeautifulSoup
  3. Independent screen scraping work time: Choose you own site to screen scrape--meaning pull stuff out of the raw HTML and format it for storing in python objects, databases, etc.
  4. Design final project interface: methods, user functions, etc.
  5. Project work time and conferencing

editMid-week ToDOs

We want to come in next week with a solid project plan, ready to work with Databases and python for at least one week. Please find time to create working programs that call at least one API and computes some value using data from that API (such as average sizes of products, etc.). Also, choose a site to scrape some data from and present that to the class next week.

cakeProducts to Produce

  • Upload your a python files related to your API calls to your GitHub account. I suggest creating a subdirectory in your git repository called "api_practice" or something like that. Once uploaded, make sure the files are publicly accessible, and then complete an entry in this code tracking spreadsheet.

Week 10: Tuesday, 10 April - Monday, 16 April

check_circleLearning Objectives

  • Diagram the flow of data between a client and a server of an Application Programming Interface (API) for a generic service
  • Use the HTTP REST protocol to make calls to an API that returns JSON-formatted Data
  • Process returned JSON data to create meaningful information from the API-returned data

listLesson Sequence

API Basics: Code-Along

This sequence will expose students to the fundamentals of an API for accessing data hosted by a third-party server and made accessible to parties through a standardized, platform-neutral protocol. We start with some essential documentation on the internet systems that allow APIs to exist. Then, we'll code python to explore the Internet Archive's Open Library API.

  • Review of the fundamentals of SOAP protocols and RESTful web services
  • Explore two core structured document formats that one works with often in Python: JSON (javascript object notation) and XML (Extensible markup language). Tufts university has an extensive write-up of the two structures.
  • JSON processing comes baked into Python. XML parsing must be done with external libraries, such as xmltodict, which can be installed via pip (the python install tool).

Mid-week ToDOs

Please create a program that calls an API of your choosing from the online index of available APIs called ProgrammableWeb.com. Use our sample code on GitHub and from last class to create a program that calls one of these APIs, retrieves a JSON file from the server, and parses that JSON file to produce some kind of output that is useful. Remember, this can be very simple: create an average of some quantitative measurement returned, etc.

cakeProducts to Produce

  • Upload your a python files related to your API calls to your GitHub account. I suggest creating a subdirectory in your git repository called "api_practice" or something like that. Once uploaded, make sure the files are publicly accessible, and then complete an entry in this code tracking spreadsheet.

Week 9: Tuesday, 3 April - Monday, 9 April

check_circleLearning Objectives

  • Explain the value of module programming and how it is implemented in Python
  • Design a modular system with classmates that distributes tasks among sevearal different python files and tools within those files
  • Use costom modules in a python program to accomplish a useful task

listLesson Sequence

Post-Break warm-ups

  1. Create a dictionary of the days of the week of break and any interesting activities that occured during those days as the values in the dictionary.
  2. Create a method that accesses this dictionary and returns the activity that was engaged in on that particular day
  3. Add user input to this program such that the day of the week can be entered and the activity is displayed.
  4. Share your files with one another as modules and create a multi-module program that, when the day of the week is entered, each person's activity is displayed by calling the relevant method from each person's module.

Continued project design and work time

Mid-week ToDOs

We will be doing screen scraping next week, which involves learning about how the HTTP protocol is used on the World Wide Web for transferring information between computers. Please review the following documentation resources this week AND write a small program that uses the python Requests module in some way.

cakeProducts to Produce


Week 8: Tuesday 20 March - Monday 2 April (enjoy spring break!)

check_circleLearning Objectives

  • Mathematical algorithm development
  • Use string conversions to correctly build text outputs

listLesson Sequence

  1. Review methods exercises from the previous week: compare solutions, find bugs, celebrate learning.
  2. Math algorithm practice: areas, distances, physics, etc.
  3. Method writing practice with string conversions
  4. String formatting example with named greetings

String formatting program specification

  1. Download the following text file of names: file link
  2. Your desired program output is a formal greeting for individuals whose names exist in a text file in the order: first last. The output should look like this:
  3. output
  4. The process of generating these greetings should take place in two methods: one should read in a file given a file name (assumed to be in the working directory) and extract the name in a single line. The second method should receive a line of text (i.e. a name in the form first last) and generate the greeting. Remember, you'll need to invert the string since we're using string formatting, not string concatenation.

extensionMid-week to-dos

cakeProducts to Produce


Week 2: Tuesday 6 Feb - Monday 12 Feb

Data structures and file management

check_circle

Learning Objectives

  1. Generate code that can interact with Lists and Dictionaries in a structured and anticipated way
  2. Write code to read in a CSV file and ouput data to a similar data structure for processing
format_list_numbered

Lesson Sequence

  1. We're going to create a shared applicaiton for reading and writing data of a defined structures.
  2. Choose a set of information that we want to organize into data structures and generate basic statis and prints

Week 4: Tuesday 20 Feb - Monday 26 Feb 2018

Manipulating and sharing dictionary-based data objects in Python

This session will continue our dictionary-based explorations from last week where we created a data structure for something we find interesting. We'll review the structure designed for traversing the dictionary tree and then discuss methods of looping and user control for actually building complex dictionary data structures by the user and then exporting this data into CSV and JSON formats for use by other applications.

check_circleLearning Objectives

bookLearning Resources

  1. Python documentation on dictionaries
  2. Python documentation on pickle

listLesson Sequence:

  1. Ensure that you have access to a version control system like GitHub or Subversion and can post files to it and share them. With this verified, create a new repository called python2ccac and create a basic readme file in there about yourself and your desires for the course.

extensionMid-week to-dos

For class on the 27th of February, please complete the following in a python program and upload it to your github. Then link this in our shared google drive:

cakeProducts to Produce


Week 5: Tuesday 27 Feb - Monday 5 March 2018

File IO in Python

check_circleLearning Objectives

bookLearning Resources

  1. Python documentation Fule I/O
  2. Python documentation on pickle

listLesson Sequence:

  1. File group-coding practice
  2. File challenge problems
  3. Dictionaries and files group-coding practice
  4. Baking in file I/O into sample dictionary processor from last week

Primitive File I/O Challenge Questions:

Challenge 1: Printing pyramids to the file

Study the following file contents. Generate a program in Python to reproduce this structure. NOTE: You'll need to use two for() loops, nested. You can try seeing if you can print the pattern out first to the console, then replace the calls to print() with calles to yourfile.write().

file example

extensionMid-week to-dos

Sections of book (introducing Python) to read for 6 March 2018

Tasks for next week

Code samples and files:

Directory listing of our course directory. See jailprocessing.py for the master CSV code we worked in class.

cakeProducts to Produce


Week 6: Tuesday 6 March - Monday 12 March 2018

check_circleLearning Objectives

listLesson Sequence:

  1. Study and run our simulator test code located on GitHub
  2. Tinker with the simulator code to adjust the number of tests and the threshold values
  3. Refactor the code to output basic test-by-test data as the loop executes, as well as the summary metrics
  4. Experiment with various probability distributions that are available through python. Note: you'll adjust these settings when you import your particular member in the package random.


Week 7: Tuesday 13 March - Monday 19 March 2018

check_circleLearning Objectives

  • Write methods with input parameters and return values
  • Debug issues with string manipulation

extensionMid-week to-dos

Please write three methods this week: one method for each mini flow-chart. If you are ambitious, implement the basic formula for standard deviation for the last method.

cakeProducts to Produce