20.179

Introduction to Programming, January 2007
This student-run course ("20.179") is desgined to provide an introduction to computer programming for those with absolutely no programming experience. The course focuses on the thought process behind writing programs, and aims to separate the tasks of algorithm design and implementation. 20.179 is designed for sophomores in Biological Engineering, but will benefit anyone who seeks an introduction to computer programming.

Workload
Two hours a day for 9 days should be sufficient, depending on the amount of material we want to include. Problem sets would be given nightly, collected the next day, and graded, and would be designed to take no more than an hour to complete. They would also be discussed at the beginning of class for ~10 minutes each day as a review of the previous material.

WORK IN PROGRESS - 9/28 18:15 EST

List of Concepts

 * 1) Thinking in Algorithms
 * 2) *What is an algorithm?
 * 3) *What tools are there?
 * 4) **Data structures: int, float, str, char (save list, dict for later)
 * 5) **operations: +, -, concatenate, =, etc.
 * 6) **logic: ==, !=, <, >, >=, <=, or, and, &, |, etc.
 * 7) *Python IDLE GUI: intro to error messages and the debugger
 * 8) *"Hello World" in Python versus some other examples
 * 9) *Intro to Python online help
 * 10) Common progamming instructions
 * 11) *Conditionals: if...elif...else
 * 12) *Simple algorithms with if...else
 * 13) *Loops - a conditional that runs i times or until a condition is true
 * 14) **For vs. while (same result, different logic and code)
 * 15) *Several examples with loops/if...else
 * 16) Tools for decomposing difficult problems
 * 17) *Concept of a function as an independent algorithm
 * 18) *Pseudocode functions - miniature programs
 * 19) *Writing and using functions in Python
 * 20) More advanced manipulation of data types
 * 21) *Re-introduce Python help
 * 22) *Discuss a problem that requires use of built-in str functions, then find those and implement it
 * 23) *Introduction of list and dict types
 * 24) *File I/O and runtime user input (raw_input)
 * 25) *Type casting
 * 26) Recursion and computational time
 * 27) *Mathematical recursion - factorial, etc.
 * 28) *Recursion in computational algorithms
 * 29) *Speed - intuitive fact function is O(2^n) - but this can be corrected!
 * 30) *The dorm arrangement + prefs list problem, also 2^n, but can't be changed.
 * 31) Classes
 * 32) *Why are they useful? Makes representing complex data easy
 * 33) *Several non-coded examples
 * 34) *Coded example with basic syntax (___init___, easy member functions and data structures)
 * 35) Anything else we want to cover
 * 36) 2-3 day Project (groups of 2-3)

Random Notes

 * 1) Day 1:
 * 2) * Distinguish writing a .py file and running it vs. just typing your commands into the >>> prompt.
 * 3) * With data types: note that each data type has a set of "methods." No need to go into great detail, but get students used to the idea that your type defines what sorts of things you can do.  For instance, strings allow you to "find."
 * 4) ** No one memorizes all of these methods - they're right there in Python help!
 * 5) * Comments use the pound sign (or multiple pound signs). Alt+3 is comment out, alt+4 is uncomment.  Leave notes for future reference (and your TAs).
 * 6) * Variables and variable names - how to choose good names (too long = you'll mistype = waste time debugging; too short = what is this variable again?), and naming conventions (don't use spaces ..).
 * 7) * Logic vs. operations: == is not = --> distinguish "store this into this variable" and "is this equal to this?" Note that strings (and everything else) can be equal, not just numbers.
 * 8) * With the basic types: note that they can be interconverted. str(3) makes '3'.
 * 9) ** Just a note to ease frustration: use \' to type an apostrophe in a string! Also, you can use " or ' to make a string, or three apostrophes for a multiline string (don't scroll off the edge of the world to read your paragraph-long string ...)
 * 10) * With basic operations: the divide symbol currently does this stupid "floor" function. You need to be careful about this!  But it'll probably change in the next Python release.
 * 11) * 50% or more of programming is debugging. What's the fastest way (besides "ask a friend")?  How to use "print" to your advantage: you can't diagnose a disease in the liver by looking at someone's clothes.
 * 12) * Python's "white space" thing - emphasize the importance of lining up your lines!
 * 13) Day 2:
 * 14) * Loops: "for" may be more annoying at times, but "while" can make your computer crash ... how to prevent the infinite while loop before it happens.
 * 15) * I think we should introduce lists, at least, by day 2. They're almost indispensable.  Either that or introduce tuples like (1,2,3).  Some way to deal with groupings.  For loops especially like to take in lists.  The range function makes a list.
 * 16) ** Make note of how the for loop syntax works - it's so different from language to language. for variable in thisRange:
 * 17) ** Don't use the same variable for nested for loops, but it's fine for subsequent ones.
 * 18) ** Distinguish using the list's ELEMENTS vs. the list's INDICES as the for loop iteration. Suppose myList = ['cat'].  If we say " for i in myList," i becomes 'cat.'  If we say 'for i in range(0,len(myList)),' i is 0.  This is a key difference if we want to call myList[i]: the former will fail.  There are times when each might be appropriate.
 * 19) ** Note that everything in Python likes to start counting from 0!
 * 20) Day 3:
 * 21) * When discussing basic functions (we need to keep it really simple!), also note what a "module" is. No need to make modules, but know how to use the ones in Python. Note that ALL .py files can be modules!
 * 22) ** For instance, suppose we want the date and time. It's very simple if we just type "import dateTime" at the top and use the various date functions.
 * 23) Day 4:
 * 24) * As I mentioned earlier, I think lists should be introduced on Day 2.
 * 25) * File I/O: you can directly feed, or you can pickle stuff, too. You can name your files however you want!
 * 26) * Dictionaries: keys vs. values. Keys can be numbers or strings, but not lists.
 * 27) * You can have a list of lists of lists, or a dictionary with lists as the values, or a dictionary of dictionaries.
 * 28) Day 5:
 * 29) * Huh? Dorm arrangements?
 * 30) Day 6:
 * 31) * With classes, draw analogies to real-life "classes" in our conceptual thinking.
 * 32) ** You can have subclasses and superclasses.
 * 33) * -- this section by Justin

Comments? Suggestions?

WORK IN PROGRESS - 9/28 18:35 EST