Lec4AccumPattern

Lec4AccumPattern - Last time functions and for loops...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Last time: functions and for loops abstraction – remove the details of a concept generalization – you look at several specific concepts and develop a theory that works for all of them – you look at several specific problems (and solutions to those problems), you figure out the pattern (similarities & differences), and you develop a single solution that works for all of those specific problems drawPolygon - what are the similarities in how to draw all polygons - what are the differences - How can I write one function that takes advantage of the similarities but still accounts for the differences def drawSquare(turtle): turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) def drawHexagon(turtle): turtle.forward(100) turtle.left(60) turtle.forward(100) turtle.left(60) turtle.forward(100) turtle.left(60) turtle.forward(100) turtle.left(60) turtle.forward(100) turtle.left(60) turtle.forward(100) turtle.left(60)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/27/2011 for the course CMPSC 8 taught by Professor Franklin during the Fall '09 term at UCSB.

Page1 / 2

Lec4AccumPattern - Last time functions and for loops...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online