Homework #9:
-
The file lsystem2.py was downloaded and a test function was written at the bottom of the file.
Next, the rest of the specifed functions were written. The file parse.py was used to read the Lsystem
and draw trees with the turtle. parse.py was modified as parse2.py to create a half a dozen trees.
-
"self.baseString = baseString" - this holds a letter, F, and is what is replaced by the rule.
"self.rules = rules" - this holds a string of letters which replaces the basestring, F.
"self.iterations = iterations" - This holds a number that represents the number of times the rule will replace the baseString.
"self.angle = angle" - This is the angle at which the turtle will draw, represented by the letter F.
"self.distance = distance" - This is the distance the turtle will draw, represented by the letter F.
-
The class Lsystem from lsystem2.py is imported into parse2.py. Objects were created to run through the class
and assigned to lsystems. The variables were assigned to a list and the string was processed in a loop to
draw each object. The Lsystems used to draw the trees are as follows:
-