# Lesson 1
## Useful Code
### Moving the Turtle
```python
turtle.forward(100)
turtle.back(50)
turtle.right(90)
turtle.left(45)
turtle.goto(10,10)
turtle.home()
turtle.setheading(0)
```
### Changing the Pen
```python
turtle.pencolor('red')
turtle.penup()
turtle.pendown()
turtle.pensize(4)
```
### Changing the Board
```python
turtle.reset()
turtle.bgcolor('blue')
turtle.showturtle()
turtle.hideturtle()
```
## Exercise
Draw the following
1. A square with sides of length 100
2. An equilateral triangle with sides of length 80
3. A noughts and crosses board
4. Draw a star by turning an angle of 144 degrees.
5. A red hexagon on a blue background.
# Lesson 2
The following program draws a purple square with a black border. Note the use of begin\_fill() and end\_fill()
```python
import turtle
turtle.fillcolor('purple')
turtle.pencolor('black')
turtle.begin_fill()
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.end_fill()
```
The above requires a lot of cut and paste code: always a sign that there is a better way of doing things. Here's one way:
```python
import turtle
turtle.fillcolor('purple')
turtle.pencolor('black')
turtle.begin_fill()
for times in range(4):
turtle.forward(100)
turtle.left(90)
turtle.end_fill()
```
We are going to be drawing lots of squares. We can define the code to draw a square as a function, that way we can reuse it. (Learning to use functions is the main reason we are using turtle graphics!)
```python
import turtle
def square():
for times in range(4):
turtle.forward(100)
turtle.left(90)
turtle.fillcolor('purple')
turtle.pencolor('black')
turtle.begin_fill()
square()
turtle.end_fill()
```
We can add a size **parameter** to the function. Now we can draw squares of different sizes.
```python
import turtle
def square(size):
for times in range(4):
turtle.forward(size)
turtle.left(90)
square(50)
square(100)
square(200)
```
## Exercise
1. Enter the following code and run it. Make sure you understand what it's doing.
```python
import turtle
def square():
for times in range(4):
turtle.forward(100)
turtle.left(90)
for n in range(8):
square()
turtle.right(45)
```
2) What do you think the following code will do? Enter it and run it.
```python
import turtle
def square(size):
for times in range(4):
turtle.forward(size)
turtle.left(90)
for n in range(8):
square(20*n)
```
3) Define a function to draw a triangle.
1. Use your triangle function to draw the following shape
![[pyturtle hexagon.png|300]]
2. Draw a circle (Hint: turn the turtle through an angle of 1 degree 360 times)
## Extension
1. Write a function to draw a pentagon
2. Write a function to draw a hexagon
3. Draw a function that accepts a parameter number\_of\_sides that draws a polygon with that number of sides
4. Write a function to draw a chessboard
5. Write a function to draw a honeycomb