CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer...

90
CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26, 2009

Transcript of CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer...

Page 1: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

CHAPTER SIXFUNCTIONS

CSC 161: The Art of Computer ProgrammingMatt Post (grad TA; guest lecturer)

10/26/2009

Monday, October 26, 2009

Page 2: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

COURSE STATUS

2Monday, October 26, 2009

Page 3: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

COURSE STATUS

2

• Programming assignment 6: Graphics (part 2)

• Due 10 AM October 31 (this Saturday)

• To be completed in teams of two

Monday, October 26, 2009

Page 4: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

COURSE STATUS

2

• Programming assignment 6: Graphics (part 2)

• Due 10 AM October 31 (this Saturday)

• To be completed in teams of two

• Midterm exam

• should have grades by this Wednesday

Monday, October 26, 2009

Page 5: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

COURSE STATUS

2

• Programming assignment 6: Graphics (part 2)

• Due 10 AM October 31 (this Saturday)

• To be completed in teams of two

• Midterm exam

• should have grades by this Wednesday

• For Wednesday

• make sure you’ve read Chapter 6

Monday, October 26, 2009

Page 6: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

3

Head of an Old Peasant Woman. Pieter Brueghel the Elder  c. 1565.

Monday, October 26, 2009

Imagine you’re a peasant woman in 19th century England. Use this painting to seed your imagination (ignoring the fact that this is a 16th century peasant woman).

Page 7: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

MAKING BREAD (CA. 200 YEARS AGO)

4Monday, October 26, 2009

This is just part of your tedious quotidian routine: making bread. If only there was a way out of it.

Page 8: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

MAKING BREAD (CA. 200 YEARS AGO)

• Wake up at 3 AM, put on bear skin or whatever

4Monday, October 26, 2009

This is just part of your tedious quotidian routine: making bread. If only there was a way out of it.

Page 9: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

MAKING BREAD (CA. 200 YEARS AGO)

• Wake up at 3 AM, put on bear skin or whatever

• Sift the bugs out of a few cups of flour, mix with some water and yeast and a little honey

4Monday, October 26, 2009

This is just part of your tedious quotidian routine: making bread. If only there was a way out of it.

Page 10: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

MAKING BREAD (CA. 200 YEARS AGO)

• Wake up at 3 AM, put on bear skin or whatever

• Sift the bugs out of a few cups of flour, mix with some water and yeast and a little honey

• Knead until you can no longer bear the pain in your wrists (you have carpal tunnel)

4Monday, October 26, 2009

This is just part of your tedious quotidian routine: making bread. If only there was a way out of it.

Page 11: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

MAKING BREAD (CA. 200 YEARS AGO)

• Wake up at 3 AM, put on bear skin or whatever

• Sift the bugs out of a few cups of flour, mix with some water and yeast and a little honey

• Knead until you can no longer bear the pain in your wrists (you have carpal tunnel)

• Set aside to rise; meanwhile, bring in some wood and use hot coals from yesterday to start a fire (walk to the neighbor’s house if your coals died)

4Monday, October 26, 2009

This is just part of your tedious quotidian routine: making bread. If only there was a way out of it.

Page 12: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

MAKING BREAD (CA. 200 YEARS AGO)

• Wake up at 3 AM, put on bear skin or whatever

• Sift the bugs out of a few cups of flour, mix with some water and yeast and a little honey

• Knead until you can no longer bear the pain in your wrists (you have carpal tunnel)

• Set aside to rise; meanwhile, bring in some wood and use hot coals from yesterday to start a fire (walk to the neighbor’s house if your coals died)

• et cetera ad nauseum

4Monday, October 26, 2009

This is just part of your tedious quotidian routine: making bread. If only there was a way out of it.

Page 13: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

5Monday, October 26, 2009

There was a way out of it! If you were rich (like Queen Victoria), you could...

Page 14: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

• Wake up at 3 AM, put on bear skin or whatever

• Sift the bugs out of a few cups of flour, mix with some water and yeast and a little honey

• Knead until you can no longer bear the pain in your wrists (you have carpal tunnel)

• Set aside to rise; meanwhile, bring in some wood and use hot coals from yesterday to start a fire (walk to the neighbor’s house if your coals died)

• et cetera ad nauseum

6http://tinyurl.com/yz4mphd

Monday, October 26, 2009

order a servant to do it!

Page 15: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

6

• Wake up at 3 AM, put on bear skin or whatever

• Sift the bugs out of a few cups of flour, mix with some water and yeast and a little honey

• Knead until you can no longer bear the pain in your wrists (you have carpal tunnel)

• Set aside to rise; meanwhile, bring in some wood and use hot coals from yesterday to start a fire (walk to the neighbor’s house if your coals died)

• et cetera ad nauseumMake bread!

http://tinyurl.com/yz4mphd

Monday, October 26, 2009

order a servant to do it!

Page 16: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

http://tinyurl.com/yzn2quw7Monday, October 26, 2009

Instead of doing all those little jobs herself, the Queen just tells the servant to do it, and the servant delivers.

Page 17: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

http://tinyurl.com/yzn2quw7

Make bread!

Monday, October 26, 2009

Instead of doing all those little jobs herself, the Queen just tells the servant to do it, and the servant delivers.

Page 18: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

http://tinyurl.com/yzn2quw7

Make bread!

Monday, October 26, 2009

Instead of doing all those little jobs herself, the Queen just tells the servant to do it, and the servant delivers.

Page 19: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

EXTENDING THE ANALOGY

8Monday, October 26, 2009

Modern programming languages (like Python) make Queens of us all. Instead of painstakingly specifying the pieces of a task over and over again, we simply define a function, give it some parameters to allow it’s behavior to vary slightly, and the receive the results of its work.

Page 20: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

EXTENDING THE ANALOGY

• The Queen

8Monday, October 26, 2009

Modern programming languages (like Python) make Queens of us all. Instead of painstakingly specifying the pieces of a task over and over again, we simply define a function, give it some parameters to allow it’s behavior to vary slightly, and the receive the results of its work.

Page 21: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

EXTENDING THE ANALOGY

• The Queen

• can specify necessary or more detailed information

8Monday, October 26, 2009

Modern programming languages (like Python) make Queens of us all. Instead of painstakingly specifying the pieces of a task over and over again, we simply define a function, give it some parameters to allow it’s behavior to vary slightly, and the receive the results of its work.

Page 22: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

EXTENDING THE ANALOGY

• The Queen

• can specify necessary or more detailed information

• “Make rye bread!” make_bread(‘rye’)

8Monday, October 26, 2009

Modern programming languages (like Python) make Queens of us all. Instead of painstakingly specifying the pieces of a task over and over again, we simply define a function, give it some parameters to allow it’s behavior to vary slightly, and the receive the results of its work.

Page 23: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

EXTENDING THE ANALOGY

• The Queen

• can specify necessary or more detailed information

• “Make rye bread!” make_bread(‘rye’)

• “Make rye bread, quickly!” make_bread(‘rye’,’fast’)

8Monday, October 26, 2009

Modern programming languages (like Python) make Queens of us all. Instead of painstakingly specifying the pieces of a task over and over again, we simply define a function, give it some parameters to allow it’s behavior to vary slightly, and the receive the results of its work.

Page 24: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

EXTENDING THE ANALOGY

• The Queen

• can specify necessary or more detailed information

• “Make rye bread!” make_bread(‘rye’)

• “Make rye bread, quickly!” make_bread(‘rye’,’fast’)

• does not know (or care) about the details of how the task is accomplished

8Monday, October 26, 2009

Modern programming languages (like Python) make Queens of us all. Instead of painstakingly specifying the pieces of a task over and over again, we simply define a function, give it some parameters to allow it’s behavior to vary slightly, and the receive the results of its work.

Page 25: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

EXTENDING THE ANALOGY

• The Queen

• can specify necessary or more detailed information

• “Make rye bread!” make_bread(‘rye’)

• “Make rye bread, quickly!” make_bread(‘rye’,’fast’)

• does not know (or care) about the details of how the task is accomplished

• can ask for anything to be sent back

8Monday, October 26, 2009

Modern programming languages (like Python) make Queens of us all. Instead of painstakingly specifying the pieces of a task over and over again, we simply define a function, give it some parameters to allow it’s behavior to vary slightly, and the receive the results of its work.

Page 26: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

EXTENDING THE ANALOGY

• The Queen

• can specify necessary or more detailed information

• “Make rye bread!” make_bread(‘rye’)

• “Make rye bread, quickly!” make_bread(‘rye’,’fast’)

• does not know (or care) about the details of how the task is accomplished

• can ask for anything to be sent back

• “Make tens loaves of rye!”loaves_list = make_bread(‘rye’,’fast’,10)

8Monday, October 26, 2009

Modern programming languages (like Python) make Queens of us all. Instead of painstakingly specifying the pieces of a task over and over again, we simply define a function, give it some parameters to allow it’s behavior to vary slightly, and the receive the results of its work.

Page 27: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

9

WHY?ELIMINATINGREDUNDANCY

Monday, October 26, 2009

We now discuss details of how functions help eliminate wasteful and error-prone repetition.

Page 28: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

10http://www.cwac.net/forests/forest.JPG

eliminating redundancy

Monday, October 26, 2009

You are a programmer on a low-budget B-grade horror movie. Your job is to create the sound of the monster making its way through the forest to the hapless cottage guests.

Page 29: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

10http://www.cwac.net/forests/forest.JPG

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

eliminating redundancy

Monday, October 26, 2009

You are a programmer on a low-budget B-grade horror movie. Your job is to create the sound of the monster making its way through the forest to the hapless cottage guests.

Page 30: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

10http://www.cwac.net/forests/forest.JPG

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

eliminating redundancy

Monday, October 26, 2009

You are a programmer on a low-budget B-grade horror movie. Your job is to create the sound of the monster making its way through the forest to the hapless cottage guests.

Page 31: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

10http://www.cwac.net/forests/forest.JPG

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

eliminating redundancy

Monday, October 26, 2009

You are a programmer on a low-budget B-grade horror movie. Your job is to create the sound of the monster making its way through the forest to the hapless cottage guests.

Page 32: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

10http://www.cwac.net/forests/forest.JPG

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

...

eliminating redundancy

Monday, October 26, 2009

You are a programmer on a low-budget B-grade horror movie. Your job is to create the sound of the monster making its way through the forest to the hapless cottage guests.

Page 33: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

11

eliminating redundancy

Monday, October 26, 2009

Instead of typing the guttural utterances over and over, we make a function that does it...

Page 34: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

11

def noise():print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

eliminating redundancy

Monday, October 26, 2009

Instead of typing the guttural utterances over and over, we make a function that does it...

Page 35: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

12

eliminating redundancy

prints

Monday, October 26, 2009

and call that function three times, which yields the same output.

Page 36: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

12

noise()noise()noise()

eliminating redundancy

prints

Monday, October 26, 2009

and call that function three times, which yields the same output.

Page 37: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

12

noise()noise()noise()

eliminating redundancy

prints

blah blah blarghblah blah blarghblarghblah blah blarghblah blah blarghblarghblah blah blarghblah blah blarghblargh

Monday, October 26, 2009

and call that function three times, which yields the same output.

Page 38: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

13

eliminating redundancy

12

3

4

5

6

7

8

Monday, October 26, 2009

In the main body of the code (left box), each time the noise() function is invoked, execution proceeds into the body of that function until it reaches the end. Then execution returns to where it left off.

Page 39: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

13

noise()noise()noise()

eliminating redundancy

12

3

4

5

6

7

8

Monday, October 26, 2009

In the main body of the code (left box), each time the noise() function is invoked, execution proceeds into the body of that function until it reaches the end. Then execution returns to where it left off.

Page 40: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

13

noise()noise()noise()

eliminating redundancy

def noise():print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’1

2

3

4

5

6

7

8

Monday, October 26, 2009

In the main body of the code (left box), each time the noise() function is invoked, execution proceeds into the body of that function until it reaches the end. Then execution returns to where it left off.

Page 41: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

13

noise()noise()noise()

eliminating redundancy

def noise():print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

def noise():print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

12

3

4

5

6

7

8

Monday, October 26, 2009

In the main body of the code (left box), each time the noise() function is invoked, execution proceeds into the body of that function until it reaches the end. Then execution returns to where it left off.

Page 42: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

13

noise()noise()noise()

eliminating redundancy

def noise():print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

def noise():print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

def noise():print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

12

3

4

5

6

7

8

Monday, October 26, 2009

In the main body of the code (left box), each time the noise() function is invoked, execution proceeds into the body of that function until it reaches the end. Then execution returns to where it left off.

Page 43: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

14

capitalizing on similarity

http://www.potteryhouse.co.uk/photogallery/spring2006/DSCF7434.JPGhttp://tinyurl.com/yzkldcf

Monday, October 26, 2009

Now imagine that we want to vary the monster’s noise as it approaches its target. We still have a lot of redundancy, except for the third gurgle in each block.

Page 44: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

14

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

capitalizing on similarity

http://www.potteryhouse.co.uk/photogallery/spring2006/DSCF7434.JPGhttp://tinyurl.com/yzkldcf

Monday, October 26, 2009

Now imagine that we want to vary the monster’s noise as it approaches its target. We still have a lot of redundancy, except for the third gurgle in each block.

Page 45: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

14

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

print ‘blah blah blargh’print ‘blah blah blargh’print ‘BLAARGH’

capitalizing on similarity

http://www.potteryhouse.co.uk/photogallery/spring2006/DSCF7434.JPGhttp://tinyurl.com/yzkldcf

Monday, October 26, 2009

Now imagine that we want to vary the monster’s noise as it approaches its target. We still have a lot of redundancy, except for the third gurgle in each block.

Page 46: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

14

print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

print ‘blah blah blargh’print ‘blah blah blargh’print ‘BLAARGH’

print ‘blah blah blargh’print ‘blah blah blargh’print ‘BLAAAARGH’

capitalizing on similarity

http://www.potteryhouse.co.uk/photogallery/spring2006/DSCF7434.JPGhttp://tinyurl.com/yzkldcf

CENSORED

Monday, October 26, 2009

Now imagine that we want to vary the monster’s noise as it approaches its target. We still have a lot of redundancy, except for the third gurgle in each block.

Page 47: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

15

def noise(final):print ‘blah blah blargh’print ‘blah blah blargh’print final

def noise():print ‘blah blah blargh’print ‘blah blah blargh’print ‘blargh’

eliminating redundancy

PARAMETERIZING THE FUNCTION

Monday, October 26, 2009

By adding a formal parameter to the noise() function specification, we allow it to vary what is printed on the third line.

Page 48: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

16

eliminating redundancy

prints

Monday, October 26, 2009

Now we can achieve the same result by passing in a different argument each time we call noise(). An argument is what we call the value being passed to the function from the caller’s perspective. When we do this, the value that is passed into the function is bound to the value of the formal parameter listed in the function’s definition.

Page 49: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

16

noise(‘blargh’)

eliminating redundancy

blah blah blarghblah blah blarghblargh

prints

Monday, October 26, 2009

Now we can achieve the same result by passing in a different argument each time we call noise(). An argument is what we call the value being passed to the function from the caller’s perspective. When we do this, the value that is passed into the function is bound to the value of the formal parameter listed in the function’s definition.

Page 50: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

16

noise(‘blargh’)

noise(‘BLAARGH’)

eliminating redundancy

blah blah blarghblah blah blarghblargh

prints

blah blah blarghblah blah blarghBLAARGH

Monday, October 26, 2009

Now we can achieve the same result by passing in a different argument each time we call noise(). An argument is what we call the value being passed to the function from the caller’s perspective. When we do this, the value that is passed into the function is bound to the value of the formal parameter listed in the function’s definition.

Page 51: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

16

noise(‘blargh’)

noise(‘BLAARGH’)

noise(‘BLAAAARGH’)

eliminating redundancy

CENSORED

blah blah blarghblah blah blarghblargh

prints

blah blah blarghblah blah blarghBLAARGHblah blah blarghblah blah blarghBLAAAARGH

Monday, October 26, 2009

Now we can achieve the same result by passing in a different argument each time we call noise(). An argument is what we call the value being passed to the function from the caller’s perspective. When we do this, the value that is passed into the function is bound to the value of the formal parameter listed in the function’s definition.

Page 52: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

17

def noise(final = ‘blargh’):print ‘blah blah blargh’print ‘blah blah blargh’print final

def noise(final):print ‘blah blah blargh’print ‘blah blah blargh’print final

eliminating redundancy

USING A DEFAULT VALUE

Monday, October 26, 2009

A small note: formal parameters can be given default values, so that if the function is called without any argument, the parameter will receive this default value.

Page 53: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

18

eliminating redundancy

prints (the same)

Monday, October 26, 2009

Here we achieve the same effect by relying on the default value of the noise() function’s parameter, “blargh”.

Page 54: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

18

noise()

eliminating redundancy

prints (the same)

blah blah blarghblah blah blarghblargh

Monday, October 26, 2009

Here we achieve the same effect by relying on the default value of the noise() function’s parameter, “blargh”.

Page 55: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

18

noise()

noise(‘BLAARGH’)

eliminating redundancy

prints (the same)

blah blah blarghblah blah blarghblarghblah blah blarghblah blah blarghBLAARGH

Monday, October 26, 2009

Here we achieve the same effect by relying on the default value of the noise() function’s parameter, “blargh”.

Page 56: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

18

noise()

noise(‘BLAARGH’)

noise(‘BLAAAARGH’)

eliminating redundancy

CENSORED

prints (the same)

blah blah blarghblah blah blarghblarghblah blah blarghblah blah blarghBLAARGHblah blah blarghblah blah blarghBLAAAARGH

Monday, October 26, 2009

Here we achieve the same effect by relying on the default value of the noise() function’s parameter, “blargh”.

Page 57: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

19

def noise(final = ‘blargh’):print ‘blah blah blargh’print ‘blah blah blargh’print finalreturn len(final)

def noise(final = ‘blargh’):print ‘blah blah blargh’print ‘blah blah blargh’print final

return values

RETURN VALUES

Monday, October 26, 2009

Every function returns a value to the caller when it is finished executing. If you don’t specify a return value (using the return statement), the default value of None is used. Here, we return the length of the final monster noise as a gross approximation of how scary the noise is (we are admittedly stretching this analogy).

Page 58: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

20

return values

prints

Monday, October 26, 2009

Now that noise() returns a value, we capture it by assigning it to a variable and printing it out.

Page 59: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

20

noise()noise(‘BLAARGH’)scary_factor = noise(‘BLAAAARGH’)

print scary_factor

return values

prints

Monday, October 26, 2009

Now that noise() returns a value, we capture it by assigning it to a variable and printing it out.

Page 60: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

20

noise()noise(‘BLAARGH’)scary_factor = noise(‘BLAAAARGH’)

print scary_factor

return values

prints

9

Monday, October 26, 2009

Now that noise() returns a value, we capture it by assigning it to a variable and printing it out.

Page 61: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

21

return values

RETURN VALUES

Monday, October 26, 2009

As we noted before, previously the noise() function did not return any values, so the return value defaulted to None. This was okay, since we were not using the return value, but in general it’s a good idea to explicitly list the return value you’d like to use, even if you don’t plan on using it, to avoid confusion at a later date.

Page 62: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

21

return values

def noise(final = ‘blargh’):print ‘blah blah blargh’print ‘blah blah blargh’print finalreturn len(final)

RETURN VALUES

Monday, October 26, 2009

As we noted before, previously the noise() function did not return any values, so the return value defaulted to None. This was okay, since we were not using the return value, but in general it’s a good idea to explicitly list the return value you’d like to use, even if you don’t plan on using it, to avoid confusion at a later date.

Page 63: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

21

return values

def noise(final = ‘blargh’):print ‘blah blah blargh’print ‘blah blah blargh’print finalreturn len(final)

def noise(final = ‘blargh’):print ‘blah blah blargh’print ‘blah blah blargh’print final

returns None

RETURN VALUES

Monday, October 26, 2009

As we noted before, previously the noise() function did not return any values, so the return value defaulted to None. This was okay, since we were not using the return value, but in general it’s a good idea to explicitly list the return value you’d like to use, even if you don’t plan on using it, to avoid confusion at a later date.

Page 64: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

22

WHY?READABILITY

(MODULARITY)

Monday, October 26, 2009

Functions also improve the readability of code, which helps with long-term (and even short-term) maintainability of the code. This is a real issue with huge software projects (like, say, Microsoft Office) that have tens of millions of lines of code, but is also an issue with smaller projects. It can be hard to keep a whole program in your head, or remember why you made certain decisions.

Page 65: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

23

readability

What does this code do?

Monday, October 26, 2009

The square() function helps you remember what you meant by x * x (since square() has a quick human interpretation). That’s not that useful here, where an experienced programmer can read both of them in equal time.

Page 66: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

23

# x is an integervalue = x * x

readability

What does this code do?

Monday, October 26, 2009

The square() function helps you remember what you meant by x * x (since square() has a quick human interpretation). That’s not that useful here, where an experienced programmer can read both of them in equal time.

Page 67: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

23

# x is an integervalue = x * x

# x is an integervalue = square(x)

readability

What does this code do?

Monday, October 26, 2009

The square() function helps you remember what you meant by x * x (since square() has a quick human interpretation). That’s not that useful here, where an experienced programmer can read both of them in equal time.

Page 68: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

24

readability

What does this code do?

Monday, October 26, 2009

It’s more of an issue here. It might take you a minute to recognize that the code in the first box computes the length of a hypotenuse of a right triangle (the Euclidean distance between two points on a plane). If you put that code in a function instead, the meaning would be immediate.

Page 69: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

24

# p1 and p2 are Point objectsvalue = math.sqrt(square(p2.getX() - p1.getX())

+ square(p2.getY() - p1.getY())

readability

What does this code do?

Monday, October 26, 2009

It’s more of an issue here. It might take you a minute to recognize that the code in the first box computes the length of a hypotenuse of a right triangle (the Euclidean distance between two points on a plane). If you put that code in a function instead, the meaning would be immediate.

Page 70: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

24

# p1 and p2 are Point objectsvalue = math.sqrt(square(p2.getX() - p1.getX())

+ square(p2.getY() - p1.getY())

# p1 and p2 are Point objectsvalue = Euclidean_distance(p1,p2)

readability

What does this code do?

Monday, October 26, 2009

It’s more of an issue here. It might take you a minute to recognize that the code in the first box computes the length of a hypotenuse of a right triangle (the Euclidean distance between two points on a plane). If you put that code in a function instead, the meaning would be immediate.

Page 71: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

25

readability

What does this code do?

Monday, October 26, 2009

Even if you don’t know what the prime factorization of an integer is, you know what’s going on in Box 2, which wouldn’t be the case for Box 1.

Page 72: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

25

# x is an integerlist = []for i in range(2,x+1): while x % i == 0: list.append(i) x /= ireturn list

readability

What does this code do?

Monday, October 26, 2009

Even if you don’t know what the prime factorization of an integer is, you know what’s going on in Box 2, which wouldn’t be the case for Box 1.

Page 73: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

25

# x is an integerlist = []for i in range(2,x+1): while x % i == 0: list.append(i) x /= ireturn list

readability

What does this code do?

# x is an integerfactors = prime_factors(x)

Monday, October 26, 2009

Even if you don’t know what the prime factorization of an integer is, you know what’s going on in Box 2, which wouldn’t be the case for Box 1.

Page 74: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

26

TOPIC:VARIABLESAND SCOPE

Monday, October 26, 2009

Page 75: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

ANATOMY OF A FUNCTION

27

def myFunc(param1,param2):var1 = var2 = 1## do some stuff#return var1,var2

Monday, October 26, 2009

A function definition tells you how a function will work when it is called. A function has a name and a list of comma-separated parameters (these parameters are bound to the actual parameters when the function is called). You can have as many parameters as you like, and as few as zero.

Page 76: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

ANATOMY OF A FUNCTION

27

def myFunc(param1,param2):var1 = var2 = 1## do some stuff#return var1,var2

information in (as many args as

you want)

Monday, October 26, 2009

A function definition tells you how a function will work when it is called. A function has a name and a list of comma-separated parameters (these parameters are bound to the actual parameters when the function is called). You can have as many parameters as you like, and as few as zero.

Page 77: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

ANATOMY OF A FUNCTION

28

def myFunc(param1,param2):var1 = var2 = 1## do some stuff#return var1, var2

Monday, October 26, 2009

A function also has internal variables. These variables are not visible outside the function. The only way for a function to communicate with its caller is with its return values.

Page 78: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

ANATOMY OF A FUNCTION

28

def myFunc(param1,param2):var1 = var2 = 1## do some stuff#return var1, var2

information in (as many args as

you want)

variables(visible only in the function)

Monday, October 26, 2009

A function also has internal variables. These variables are not visible outside the function. The only way for a function to communicate with its caller is with its return values.

Page 79: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

ANATOMY OF A FUNCTION

29

def myFunc(param1,param2):var1 = var2 = 1## do some stuff#return var1,var2

Monday, October 26, 2009

You can return as many variables as you’d like. On the calling side, you assign them like this:

x,y = myFunc(arg1,arg2)

Remember that the value of arg1 (on the calling side) is assigned to param1, and the value of arg2 is assigned to param2. myFunc knows nothing about variables on the calling side unless they are passed in and assigned to its named parameters

Page 80: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

ANATOMY OF A FUNCTION

29

def myFunc(param1,param2):var1 = var2 = 1## do some stuff#return var1,var2

information in (as many args as

you want)

information out (as many return values as you

want)

variables(visible only in the function)

Monday, October 26, 2009

You can return as many variables as you’d like. On the calling side, you assign them like this:

x,y = myFunc(arg1,arg2)

Remember that the value of arg1 (on the calling side) is assigned to param1, and the value of arg2 is assigned to param2. myFunc knows nothing about variables on the calling side unless they are passed in and assigned to its named parameters

Page 81: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

CALLING A FUNCTION

30

def square(n): n2 = n * n return n2

def main(): x = input(“value? “) print x, “squared is”, square(x)

Monday, October 26, 2009

Here we see the difference between the function definition (for square()) and it being called. When main calls square(x), the value of x in main() is assigned to the formal parameter n in square().

Page 82: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

CALLING A FUNCTION

30

def square(n): n2 = n * n return n2

def main(): x = input(“value? “) print x, “squared is”, square(x)

n is a formal parameter (part of the function definition)

Monday, October 26, 2009

Here we see the difference between the function definition (for square()) and it being called. When main calls square(x), the value of x in main() is assigned to the formal parameter n in square().

Page 83: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

CALLING A FUNCTION

30

def square(n): n2 = n * n return n2

def main(): x = input(“value? “) print x, “squared is”, square(x)

n is a formal parameter (part of the function definition)

when square(x) is called, the value of x (the actual parameter is assigned to n)

Monday, October 26, 2009

Here we see the difference between the function definition (for square()) and it being called. When main calls square(x), the value of x in main() is assigned to the formal parameter n in square().

Page 84: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

SOME IMPORTANT NOTES

31Monday, October 26, 2009

Page 85: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

SOME IMPORTANT NOTES

31

• function arguments are passed by value

• this means that the value of the variable is passed, not the variable itself

• so if the function changes the value of the variable, the caller won’t see the changes

• the caller and the callee may both have different names for the value; neither knows the names the other uses (or cares)

Monday, October 26, 2009

Page 86: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

32

SUMMARY

Monday, October 26, 2009

Page 87: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

32

SUMMARY

• Scope

• All variables used by a function must be (a) declared inside the function or (b) passed in as arguments

• All variables declared in a function cease to exist afterward

Monday, October 26, 2009

Page 88: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

32

SUMMARY

• Scope

• All variables used by a function must be (a) declared inside the function or (b) passed in as arguments

• All variables declared in a function cease to exist afterward

• Pass by value

• Any modifications to arguments are lost

Monday, October 26, 2009

Page 89: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

32

SUMMARY

• Scope

• All variables used by a function must be (a) declared inside the function or (b) passed in as arguments

• All variables declared in a function cease to exist afterward

• Pass by value

• Any modifications to arguments are lost

• Communication

• In (via passed arguments) and out (via return value(s))

Monday, October 26, 2009

Page 90: CHAPTER SIX FUNCTIONS - University of Rochester...CHAPTER SIX FUNCTIONS CSC 161: The Art of Computer Programming Matt Post (grad TA; guest lecturer) 10/26/2009 Monday, October 26,

33

EXAMPLES

Monday, October 26, 2009

See annotated python examples (separate).