Recitation Homework 5
Ionut Trestian
Northwestern University
The Game of Life: History
Created by John Horton Conway,
a British Mathematician
Inspired by a problem presented
by John Von Neumann:
Build a hypothetical machine that
can build copies of its

EECS 110: Lec 5:
List Comprehensions
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
EECS 110 today
The building
blocks of
functional
computing
data, sequences
conditionals
recursion
List Comprehensions
map and

EECS 110: Lec 4:
Functions and Recursion
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
The in thing
> 3*'i' in 'alien'
False
> 'i' in 'team'
False
> 'cs' in 'physics'
True
> sleep' not in EECS 110'
True
> 42

EECS 110: Lec 10:
Definite Loops and User Input
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
Loops!
We've seen variables change in-place before:
[ x*6 for x in range(8) ]
[ 0, 6, 12, 18, 24, 30, 36, 42 ]
rem

EECS 110: Lec 12:
Mutable Data
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
EECS 110 Today
infinitely nested structure
HW 5 Preview:
Pr 1 (Lab): The Game of Life
Pr 2: Markov Text Generation
required
optiona

EECS 110: Lec 16:
Projects
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
The Rest of the Class
the view from here
Fri., 3/7
project recitations by TAs (10am)
Sun., 3/9
Interim milestones due (11:59pm)
revie

EECS 110: Lec 17:
Review for the Final Exam
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
General Info
Tuesday, 3/12, 9:00-noon, Ford ITW
To be done individually
Closed book
Please do not discuss the exam wit

EECS 110: Lec 9:
Review for the Midterm Exam
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
General Info
Wednesday, Feb 5, 9-11am or 10am-noon, FORD
ITW
To be done individually
Closed book
One 8.5 by 11 sheet

EECS 110: Introduction to
Programming for Non-Majors
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
If you take only one thing today
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
2
Who am I?
Oliver Coss

EECS 110: Lec 3: Data
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
What is programming?
Programming as learning a foreign language
1) Expect it to be different!
2) Dont feel you need to memorize it
3) Immers

Spring 2013
Evolving Lists & Lights On!
Caesar Cipher
Looks Good!
encipher(S, n)
Rotates the string S by n characters
Example:
encipher('AbC', 2) returns 'CdE'
encipher('xYz', 4) returns 'bCd'
decipher(S)
Retrieve the original string from an encipher

Spring 2012
Problems
Rock-Paper-Scissors (fair game)
Functions Frenzy
Extra Problems
Pig Latin
Scoring Paper
Objective: Play rock-paper-scissors fairly
Steps for the program:
1. Choose the computer choice randomly
(without revealing this value to the

Spring 2013
Problems:
Mandelbrot set
Time Travel Securities, Inc.
Pi from pie
Extra Credits:
Sequence Sums
The correct result:
Function tts() prints a menu
(0)
(1)
(2)
(3)
(4)
(5)
(6)
(9)
Input a new list
Print the current list
Find the average price

Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by Ca

EECS 110: Lec 2:
What is Programming?
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
Homework problems 3 and 4
Picobot
walls
Picobot
area not
covered
(yet!)
area
already
covered
Goal: whole-environment coverag

EECS 110: Lec 6:
Fractals and Turtles
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
EECS 110 Today
hw2 due Sunday evening
Fractals and Turtles!
The Koch Curve
Quiz
Write each of these functions concisely
usin

EECS 110: Lec 7:
Program Planning
Oliver Cossairt
Northwestern University
http:/ollie-imac.cs.northwestern.edu/~ollie/eecs110/
EECS 110 Today
Computing to the max
The not-so-subtle art of singling out the
best (and worst) of anything
Hw #3 due
Sunday
Ligh

Lecture 9: 10/17/2012
Can catinate and repeat and index and slice lists
Rotate program:
>Def rby1(s):
Return S[1:]+S[0]
>def rotate(s,n):
For i in range(n):
s = rby1(s)
Return s
*Efficient way to do it:
> def rotate(n,s):
return s[n%len(s):] + s[:n%len(s)

Lecture 5: 10/8/2012
Homework: read book chapters 1-3
Program that can draw a square- parameters
Orientation
Starting point
Length of the sides
Next thought: what can you do with this- make more squares? Checkerboard?
Loops- iteration
While loop
o Whi

Lecture 3: 10/3/2012
Atomic symbols: 5, 3.5, x, +, if (integer, floating point number, variable, operations)
Rules of combination: 5+7, (5+7)*2.0
Methods of packaging/abstraction/naming
Def some atomic symbol is some combination
Python is an interpreted l

Lecture 4: 10/5/2012
Def name (<pns>):
<body>
<return>
Conditional expressions (if, then, else)
Def max (a,b):
If a>b: (a boolean value expression-relation among numbers (> < =), there is a T or F)
Return a
Else: Return b
Sub each corresponding argument

Lecture 2: 10/1/2012
birnbaum@cs.northwestern.edu
Program is a recipe:
Ingredients = Data. Inputs that will be operated on by the recipe, will be transformed
Actions (chopping, baking, etc)= Actions (plus, minus, divide, etc)
Order+ = Control structure
Li