Commit 7b330fb4 authored by Greg Wilson's avatar Greg Wilson
Browse files

Moving keypoints to episodes

parent 093c00b9
......@@ -13,7 +13,20 @@ objectives:
- "Perform operations on arrays of data."
- "Display simple graphs."
keypoints:
- "FIXME"
- "Import a library into a program using `import libraryname`."
- "Use the `numpy` library to work with arrays in Python."
- "Use `variable = value` to assign a value to a variable in order to record it in memory."
- "Variables are created on demand whenever a value is assigned to them."
- "Use `print(something)` to display the value of `something`."
- "The expression `array.shape` gives the shape of an array."
- "Use `array[x, y]` to select a single element from an array."
- "Array indices start at 0, not 1."
- "Use `low:high` to specify a slice that includes the indices from `low` to `high-1`."
- "All the indexing and slicing that works on arrays also works on strings."
- "Use `# some kind of explanation` to add comments to programs."
- "Use `numpy.mean(array)`, `numpy.max(array)`, and `numpy.min(array)` to calculate simple statistics."
- "Use `numpy.mean(array, axis=0)` or `numpy.mean(array, axis=1)` to calculate statistics across the specified axis."
- "Use the `pyplot` library from `matplotlib` for creating simple visualizations."
---
Words are useful,
......
......@@ -10,7 +10,9 @@ objectives:
- "Trace changes to a loop variable as the loop runs."
- "Trace changes to other variables as they are updated by a for loop."
keypoints:
- "FIXME"
- "Use `for variable in collection` to process the elements of a collection one at a time."
- "The body of a for loop must be indented."
- "Use `len(thing)` to determine the length of something that contains other values."
---
In the last lesson,
......
......@@ -8,7 +8,10 @@ objectives:
- "Explain what a list is."
- "Create and index lists of simple values."
keypoints:
- "FIXME"
- "`[value1, value2, value3, ...]` creates a list."
- "Lists are indexed and sliced in the same way as strings and arrays."
- "Lists are mutable (i.e., their values can be changed in place)."
- "Strings are immutable (i.e., the characters in them cannot be changed)."
---
Just as a `for` loop is a way to do operations many times,
......
......@@ -8,7 +8,8 @@ objectives:
- "Use a library function to get a list of filenames that match a simple wildcard pattern."
- "Use a for loop to process multiple files."
keypoints:
- "FIXME"
- "Use `glob.glob(pattern)` to create a list of files whose names match a pattern."
- "Use `*` in a pattern to match zero or more characters, and `?` to match any single character."
---
We now have almost everything we need to process all our data files.
......
......@@ -8,7 +8,14 @@ objectives:
- "Write conditional statements including `if`, `elif`, and `else` branches."
- "Correctly evaluate expressions containing `and` and `or`."
keypoints:
- "FIXME"
- "Use `if condition` to start a conditional statement, `elif condition` to provide additional tests, and `else` to provide a default."
- "The bodies of the branches of conditional statements must be indented."
- "Use `==` to test for equality."
- "`X and Y` is only true if both X and Y are true."
- "`X or Y` is true if either X or Y, or both, are true."
- "Zero, the empty string, and the empty list are considered false; all other numbers, strings, and lists are considered true."
- "Nest loops to operate on multi-dimensional data."
- "Put code whose parameters change frequently in a function, then call it with different parameter values to customize its behavior."
---
In our last lesson, we discovered something suspicious was going on
......
......@@ -11,7 +11,17 @@ objectives:
- "Set default values for function parameters."
- "Explain why we should divide programs into small, single-purpose functions."
keypoints:
- "FIXME"
- "Define a function using `def name(...params...)`."
- "The body of a function must be indented."
- "Call a function using `name(...values...)`."
- "Numbers are stored as integers or floating-point numbers."
- "Integer division produces the whole part of the answer (not the fractional part)."
- "Each time a function is called, a new stack frame is created on the **call stack** to hold its parameters and local variables."
- "Python looks for variables in the current stack frame before looking for them at the top level."
- "Use `help(thing)` to view help for something."
- "Put docstrings in functions to provide help for that function."
- "Specify default values for parameters when defining a function using `name=value` in the parameter list."
- "Parameters can be passed by matching based on name, by position, or by omitting them (in which case the default value is used)."
---
At this point,
......
......@@ -8,7 +8,11 @@ objectives:
- "To be able to read a traceback, and determine where the error took place and what type it is."
- "To be able to describe the types of situations in which syntax errors, indentation errors, name errors, index errors, and missing file errors occur."
keypoints:
- "FIXME"
- "Tracebacks can look intimidating, but they give us a lot of useful information about what went wrong in our program, including where the error occurred and what type of error it was."
- "An error having to do with the 'grammar' or syntax of the program is called a `SyntaxError`. If the issue has to do with how the code is indented, then it will be called an `IndentationError`."
- "A `NameError` will occur if you use a variable that has not been defined, either because you meant to use quotes around a string, you forgot to define the variable, or you just made a typo."
- "Containers like lists and strings will generate errors if you try to access items in them that do not exist. This type of error is called an `IndexError`."
- "Trying to read a file that does not exist will give you an `IOError`. Trying to read a file that is open for writing, or writing to a file that is open for reading, will also give you an `IOError`."
---
Every programmer encounters errors,
......
......@@ -11,7 +11,11 @@ objectives:
- "Explain what test-driven development is, and use it when creating new functions."
- "Explain why variables should be initialized using actual data values rather than arbitrary constants."
keypoints:
- "FIXME"
- "Program defensively, i.e., assume that errors are going to arise, and write code to detect them when they do."
- "Put assertions in programs to check their state as they run, and to help readers understand how those programs are supposed to work."
- "Use preconditions to check that the inputs to a function are safe to use."
- "Use postconditions to check that the output from a function is safe to use."
- "Write tests before writing code in order to help determine exactly what that code is supposed to do."
---
Our previous lessons have introduced the basic tools of programming:
......
......@@ -8,7 +8,12 @@ objectives:
- "Debug code containing an error systematically."
- "Identify ways of making code less error-prone and more easily tested."
keypoints:
- "FIXME"
- "Know what code is supposed to do *before* trying to debug it."
- "Make it fail every time."
- "Make it fail fast."
- "Change one thing at a time, and for a reason."
- "Keep track of what you've done."
- "Be humble."
---
Once testing has uncovered problems,
......
......@@ -9,7 +9,11 @@ objectives:
- "Handle flags and files separately in a command-line program."
- "Read data from standard input in a program so that it can be used in a pipeline."
keypoints:
- "FIXME"
- "The `sys` library connects a Python program to the system it is running on."
- "The list `sys.argv` contains the command-line arguments that a program was run with."
- "Avoid silent failures."
- "The pseudo-file `sys.stdin` connects to a program's standard input."
- "The pseudo-file `sys.stdout` connects to a program's standard output."
---
The Jupyter Notebook and other interactive tools are great for prototyping code and exploring data,
......
......@@ -2,109 +2,6 @@
layout: reference
---
## [Analyzing Patient Data](01-numpy.html)
* Import a library into a program using `import libraryname`.
* Use the `numpy` library to work with arrays in Python.
* Use `variable = value` to assign a value to a variable in order to record it in memory.
* Variables are created on demand whenever a value is assigned to them.
* Use `print(something)` to display the value of `something`.
* The expression `array.shape` gives the shape of an array.
* Use `array[x, y]` to select a single element from an array.
* Array indices start at 0, not 1.
* Use `low:high` to specify a slice that includes the indices from `low` to `high-1`.
* All the indexing and slicing that works on arrays also works on strings.
* Use `# some kind of explanation` to add comments to programs.
* Use `numpy.mean(array)`, `numpy.max(array)`, and `numpy.min(array)` to calculate simple statistics.
* Use `numpy.mean(array, axis=0)` or `numpy.mean(array, axis=1)` to calculate statistics across the specified axis.
* Use the `pyplot` library from `matplotlib` for creating simple visualizations.
## [Repeating Actions with Loops](02-loop.html)
* Use `for variable in collection` to process the elements of a collection one at a time.
* The body of a for loop must be indented.
* Use `len(thing)` to determine the length of something that contains other values.
## [Storing Multiple Values in Lists](03-lists.html)
* `[value1, value2, value3, ...]` creates a list.
* Lists are indexed and sliced in the same way as strings and arrays.
* Lists are mutable (i.e., their values can be changed in place).
* Strings are immutable (i.e., the characters in them cannot be changed).
## [Analyzing Data from Multiple Files](04-files.html)
* Use `glob.glob(pattern)` to create a list of files whose names match a pattern.
* Use `*` in a pattern to match zero or more characters, and `?` to match any single character.
## [Making Choices](05-cond.html)
* Use `if condition` to start a conditional statement, `elif condition` to provide additional tests, and `else` to provide a default.
* The bodies of the branches of conditional statements must be indented.
* Use `==` to test for equality.
* `X and Y` is only true if both X and Y are true.
* `X or Y` is true if either X or Y, or both, are true.
* Zero, the empty string, and the empty list are considered false; all other numbers, strings, and lists are considered true.
* Nest loops to operate on multi-dimensional data.
* Put code whose parameters change frequently in a function, then call it with different parameter values to customize its behavior.
## [Creating Functions](06-func.html)
* Define a function using `def name(...params...)`.
* The body of a function must be indented.
* Call a function using `name(...values...)`.
* Numbers are stored as integers or floating-point numbers.
* Integer division produces the whole part of the answer (not the fractional part).
* Each time a function is called, a new stack frame is created on the **call stack** to hold its parameters and local variables.
* Python looks for variables in the current stack frame before looking for them at the top level.
* Use `help(thing)` to view help for something.
* Put docstrings in functions to provide help for that function.
* Specify default values for parameters when defining a function using `name=value` in the parameter list.
* Parameters can be passed by matching based on name, by position, or by omitting them (in which case the default value is used).
## [Errors and Exceptions](07-errors.html)
* Tracebacks can look intimidating,
but they give us a lot of useful information about what went wrong in our program,
including where the error occurred and what type of error it was.
* An error having to do with the "grammar" or syntax of the program is called a `SyntaxError`.
If the issue has to do with how the code is indented, then it will be called an `IndentationError`.
* A `NameError` will occur if you use a variable that has not been defined,
either because you meant to use quotes around a string,
you forgot to define the variable,
or you just made a typo.
* Containers like lists and strings will generate errors if you try to access items in them that do not exist.
This type of error is called an `IndexError`.
* Trying to read a file that does not exist will give you an `IOError`.
Trying to read a file that is open for writing,
or writing to a file that is open for reading,
will also give you an `IOError`.
## [Defensive Programming](08-defensive.html)
* Program defensively, i.e., assume that errors are going to arise, and write code to detect them when they do.
* Put assertions in programs to check their state as they run, and to help readers understand how those programs are supposed to work.
* Use preconditions to check that the inputs to a function are safe to use.
* Use postconditions to check that the output from a function is safe to use.
* Write tests before writing code in order to help determine exactly what that code is supposed to do.
## [Debugging](09-debugging.html)
* Know what code is supposed to do *before* trying to debug it.
* Make it fail every time.
* Make it fail fast.
* Change one thing at a time, and for a reason.
* Keep track of what you've done.
* Be humble.
## [Command-Line Programs](10-cmdline.html)
* The `sys` library connects a Python program to the system it is running on.
* The list `sys.argv` contains the command-line arguments that a program was run with.
* Avoid silent failures.
* The "file" `sys.stdin` connects to a program's standard input.
* The "file" `sys.stdout` connects to a program's standard output.
## Glossary
additive color model
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment