## CS2 Computational Thinking for Scientists - Lab 05In this lab, we will experiment with recursive Python programs for drawing fractals. I have created a Python module fractals.py. Download this module into a folder in your desktop. Run the following commands in order to import the functions in fractals.py in to your IDLE platform:import os os.chdir("/Users/koc/Desktop/abc") from fractals import *Change the file path from above to the one you will be using. Also, import the turtle and the math modules: import turtle, mathsince we will be using them as well. The following recursive functions are available in fractals.py module: -
`koch1(turtle,order,length)`: Koch fractal whose top corner points up. -
`koch2(turtle,order,length)`: Koch fractal whose top corner points down. -
`kochtr1(turtle,order,length)`: Koch triangle made up from koch1 fractals. -
`kochtr2(turtle,order,length)`: Koch triangle made up from koch2 fractals. -
`kochsq1(turtle,order,length)`: Koch square made up from koch1 fractals. -
`kochsq2(turtle,order,length)`: Koch square made up from koch2 fractals. -
`torn1(turtle,order,length)`: Torn fractal whose top corner points up. -
`torn2(turtle,order,length)`: Torn fractal whose top corner points down. -
`tornsq1(turtle,order,length)`: Torn square made up from torn1 fractals. -
`tornsq2(turtle,order,length)`: Torn square made up from torn2 fractals.
tony = turtle.Turtle() # create a turtle tony.up() # pen up tony.goto(-100,-100) # left bottom corner tony.down() # pen down koch1(tony,4,200) # order = 4 and length = 200
The lab report (if required) is due 5pm, Friday Feb 13. |