'''lecture_04_hexagon_style.py Oliver W. Layton Spring 2021 CS 151 Draws a hexagon using good coding stylistic practices ''' import turtle def triangle(): ''' Draws a triangle''' turtle.forward(100) turtle.left(120) turtle.forward(100) turtle.left(120) turtle.forward(100) turtle.left(120) def hexagon(sideLength): '''Draws a hexagon with different side length sideLength. Parameters: ----------- sideLength: int or float. The length of each side of the hexagon. ''' turtle.forward(sideLength) turtle.right(60) turtle.forward(sideLength) turtle.right(60) turtle.forward(sideLength) turtle.right(60) # At this point, we move forward by sideLength and then turn right 60 deg. # Repeat this 2 times turtle.forward(sideLength) turtle.right(60) turtle.forward(sideLength) turtle.right(60) turtle.forward(sideLength) turtle.right(60) # main code / top-level code # make the turtle draw the shape fast turtle.speed(0) # We call hexagon to draw it hexagon(100) # We keep the canvas window open until somebody clicks turtle.exitonclick()