Introductory Programming Fall 2004 For next time you should: 1) Finish Homework 4. 2) Prepare for an evaluation on Chapter 4. 3) Start Chapter 5. Functions --------- What's up with functions? Evaluation 2b solution: def vee(t, n): # draws a V and leaves the turtle facing in the original direction rt(t, 45) fd(t, n) lt(t, 90) ft(t, n) rt(t, 45) def double_yoo(t, n): vee(t, n) vee(t, n) Refactoring ----------- Read the following program to get an idea of what it does: world.clear() bob = Turtle(world) bob.delay = 0.001 bob.x = -150 bob.y = 90 bob.redraw() def koch(t, n): if n<5: fd(t, n) return n = n/3.0 koch(t, n) lt(t, 60) koch(t, n) rt(t, 120) koch(t, n) lt(t, 60) koch(t, n) for i in range(3): koch(bob, 300) rt(bob, 120) On this or a separate piece of paper, write an improved version of the program by following the instructions below. 1) Encapsulate the last three lines in a function named snowflake. 2) Generalize snowflake with appropriate parameters. 3) Refactor koch to eliminate repetitive code. 4) Apply any other transformations that you think would improve the program.