You can control where the turtle moves and where it turns:

See if you can adapt this code to draw a square