Skip to content
ligthyear edited this page Aug 28, 2012 · 23 revisions

Welcome to the python-ots wiki!

Format of our Python workshops

The format we've agreed on is:

Introduction week-end to Python for absolute beginners

That involves an install-party on the Friday evening (optional if the student already has python installed on her/his laptop), and then a Saturday afternoon introduction for absolute beginners (content to be discussed below). Contrary to the Rails Girls and JSFAB workshops there won't be anything happening on the Sunday. We will need as many coaches as possible for that week-end event in order to help the students as much as possible. If we feel the need that introduction week-end could be run on a regular basis.

Follow-up workshops with specific topics

After that initial introduction week-end we will run workshops every week or every two weeks on specific topics and/or tasks that we can do in Python. We are thinking of having them on a fix week day in the evening, starting with a max 2h workshop, followed by another hour of questions (on the workshop of the day or follow-up questions on the previous workshops). Everyone with at list a basic understanding of programming in Python (either those who attended the week-end introduction or anybody with the same or higher level) is welcome to those follow-up events. The topics will be depending on the coaches available that week (topics to be discussed below).

What our introduction to Python should contain

if/else

Write here any tasks/exercises/ideas on how to teach that concept

loops

abstractions

reading/writing files

-read file containing different products with price and category assigned; sort products by price; find the cheapest product in each category; calculate mean price for all categories; write result in a new file; (file encoding???)

Resources for the beginners workshop

The Boston Python Workshop

The Boston Python Workshop - the format is inspired by the RailsBrigde-Workshops and they provide detailed materials of their past workshops. As an example we could look at the Boston Python Workshop 6. It has the following elements:

Head First Python

The Head First books use a couple of principles to help people learn and remember stuff. We could use the stories, they wrap around the tasks to make them more interesting. There is a free sample of the Python book available.

Python for Kids

  • Interactive work (arithmetic expressions, string concatenation, print statement, module imports)
  • Simple drawing with Turtle (forward, left/right, reset, width/color)
    • Draw a rectangle
    • Draw one/many tilted rectangles
    • Other figures: triangle, house, hexagon/honeycomb
  • Names (variables, assignments, user input)
    • Draw parametrized triangles/tilted rectangles
    • Calculate average grade
  • User-defined functions (function definition, modules)
    • Isolate triangle drawing, with global variable
    • Write a quiz framework (conditional branching)
    • Write a quiz framework, with scores (globals, multiple branches)
    • Parametrize hexagon for honeycomb
  • Functions with parameters (function arguments)
    • Parametrize triangle drawing
    • Parametrize rectangle drawing (multiple arguments)
    • Jump with the turtle
    • Parametrize tilted triangle drawing (default arguments)
    • Print a soap opera (string formatting)
    • Generalize drawing functions into a single function with a type argument for rectangles, triangles, squares
    • Print a numeral from a user-supplied number between 1 and 100
    • Print a greeting card
    • Draw a right-angled triangle, and a house in one stroke from that
  • Loops (for loops through collections, range function)
    • Draw a dashed line
    • Rephrase all draw functions with loops (lists)
    • Draw a spiral of rectangles
    • Draw a n-sided shape
    • Draw rosettes (fill)
    • Formulate a better version of the quiz, now with a collection of questions
  • Conditional loops (while loops, debugger)
    • Draw a polygon which turns until it hits normal orientation again (modulo, tracer)
    • Find the minimum amount of numbers beginning from 1 which sum up to at least 1,000
    • Find the smallest number for which (1.0/n)*n != 1.0
    • Find the number of divisions by 2 until a number, say 1, hits zero
  • Guess the number -- a game (random numbers)
    • Generate a random number and get user input until she hit the correct number with lesser/greater than hints
    • Guess the number automatically
    • Throw a dice
    • Find the number of random pairs that need to be generated until both items are the same
  • Functions with values (return statement, null values)
    • Write a function returning rectangle area/circumference
    • Return a string of the supplied length, row(7) -> "IIIII II"
    • Factorial
    • Write a table-evaluating function, table(collection, func) -> func(c) for c in collection (functions as objects)
    • Benchmark a function (clock function)
  • Bonus: Draw a tree through recursion

Python Tutorials for Kids 8+

Collection of short tutorials from a guy who's teaching python to his son.

python4kids.wordpress.com (Go here and scroll down to get to the beginning)

HPI Curriculum

http://www.dcl.hpi.uni-potsdam.de/teaching/pt1/

  • Representation of information, numbers, text
  • Programming languages (categories and formal representation)
  • Algorithms and specifications
  • Subroutines
  • Exception handling
  • Construction of new datatypes
  • Verification
  • Version control
  • Object-oriented programming, classes, abstract datatypes
  • Exercises
    • Find all divisors of a number
    • Factorial
    • Find all prime factors of a factorial
    • Sum the first natural numbers
    • Approximate a number's square root (Heron)
    • Ackermann
    • Read the passwd file, search through it
    • Print/evaluate an AST
    • Implement a doubly-linked list

Projects

Projects are a way to pack the single programming concepts into something that is closer to the real world and more fun. They can be small enough to be included in the initial introduction week-end event or big enough to become one of the follow-up workshops.

Turtle

Turtle graphics is a popular way for introducing programming. It can be used to explain the core programming concepts like variables, loops, conditionals and functions.

Examples:

Twitter Client

Twitter has a search API which returns the tweets in JSON format. Some programming concepts can be explained by calling the API and analyzing the results.

  • Using the Standard Library (urllib, json)
  • Lists, Dictionaries
  • Conditionals, loops, list comprehensions
  • Handling strings
  • Recursion

Example

here is the most simple version I could come up with for a bare down twitter client introducing new concepts:

# we need help from some libraries, import them
import json
import httplib

# open a connection to an external server
twitter_connection = httplib.HTTPConnection("www.twitter.com")

# load the data via an HTTP-Get request
twitter_connection.request("GET", "/statuses/user_timeline.json?screen_name=OpenTechSchool")

# acquire the given response
response = twitter_connection.getresponse()

# read the content
response_data = response.read()

# parse the content using json
parsed_data = json.loads(respones_data)

# bonus: pretty printing
# from pprint import pprint
# pprint(parsed_data)

Python for science

Think Stats - Probability and Statistics for Programmers Think Stats is an introduction to Probability and Statistics for Python programmers. http://greenteapress.com/thinkstats/

Think Complexity - This book is about complexity science, data structures and algorithms, intermediate programming in Python, and the philosophy of science. http://greenteapress.com/compmod/

Natural Language Processing with Python - Analyzing Text with the Natural Language Toolkit. http://nltk.org/ and https://sites.google.com/site/naturallanguagetoolkit/book

scikit-learn is a Python module integrating classic machine learning algorithms in the tightly-knit scientific Python world (numpy, scipy, matplotlib). It aims to provide simple and efficient solutions to learning problems, accessible to everybody and reusable in various contexts: machine-learning as a versatile tool for science and engineering. http://scikit-learn.org/stable/

Django for webdevelopment

Django Workshop is a free Django 1.4 Tutorial (in german). http://www.django-workshop.de/ see also Django101 in the wiki

Bioinformatics in python

http://biopython.org/ - Biopython is a set of freely available tools for biological computation written in Python by an international team of developers. Biopython Tutorial and Cookbook

PsychoPy is the Psychology Software in Python for presentation of stimuli and collection of data for a wide range of neuroscience, psychology and psychophysics experiments. Can be used for creating experiments with EyeTracker, NIRS, Skin Conductance Response.PsychoPy