Hi, I just received a project in my class where i have to write my own turtle class in python which I will have to use to draw a Koch snowflake. Currently I have no idea on how to get started on the turtle class? If anyone knows or has any tip please reply! Thanks.

Actually I am new to python so I'm not really sure what you mean???

Well, now I understand koch snowflake, but how would I write the turtle class to draw it because for this project we have to write our own turtle class, this is what I have so far:

class Turtle:
    def __init__(self, location, direction):
        self.location = location
        self.direction = direction * math.pi / 180

    def moveTo(self, somePoint):
        some code..
    def draw(self, length, win):
        some code..
    def turn(self, degrees):
        some code..

I don't understand how to actually draw the line and then rotate it in python????

Edited 5 Years Ago by jum2011: n/a

You need to start out with a GUI toolkit like Tkinter that comes with Python. That will do the actual drawing.

The turtle will point in a certain direction and you have to use trigonometry to calculate the length of the line and its end point (x, y) from the angle the line has to be drawn.

This article has been dead for over six months. Start a new discussion instead.