# 1. Sequences

## 1.1. Big Question

- What is a sequence?

## 1.2. Key words

- Sequence

## 1.3. Sequences (Task 1)

First a simple sequence. It does one thing after another. Run this one line at a time, by tapping forward.

(Sequence_1)

## 1.4. Sequences (Task 2)

Sequence-2: What line is run after line 2?
- 1
- what is 2+1?
- 2
- what is 2+1?
- 3
- yes 2+1=3.
- 4
- what is 2+1?
- 5
- There is no line 5.

So far we could do that ourselves much easier. So let us look at something different. We will come back to print when we can do something interesting with it.

## 1.5. Sequences (Task 3)

Above is some scratch-like code. It makes a turtle move around, with a pen. Pretend to be a turtle, to help you work it out.

Sequence-3: What will it draw?
- A triangle
- How many corners?
- A square
- Yes, it has 4 side, and 4 corners of 90 degrees.
- A pentagon
- How many sides?
- A hexagon
- What is the angle?

## 1.6. Sequences (Task 4)

Unfortunately the designers of python turtle, did not choose such good names: `left` = `turn_left`, `forward` = `move_forward` (I don’t think they understand how to use verbs).

            Sequence-4: Rearrange to make a program that draws a square.import turtle
    turtle.forward(50)
    ---
    turtle.left(90)
    turtle.forward(50)
    turtle.left(90)
    ---
    turtle.forward(50)
    ---
    turtle.left(90)
    turtle.forward(50)
    turtle.left(90)

## 1.7. Sequences (Task 5)

Below I have started a program. Finish it, so that it draws a square. Use what you have already done to help you:

- Run the program.
- Repeat until done:
  - Add one or at most two lines.
  - Run it again, did it do what you expected? If not then fix it.

import turtle turtle.forward(50) turtle.left(90)

## 1.8. Sequences (Task 6)

The turtle moves from B to C, if it does not turn it will head of to D. It must turn toward A.

Sequence-6: What angle does it need to turn?
- a
- The turtle is at point C.
- b
- The turtle is at point C.
- c
- The turtle is facing D, and needs to face A. What angle is between them.
- d
- Yes it is the external angle d.

## 1.9. Sequences (Task 7)

Now do it again, but this time make the turtle draw a triangle. (I started it, but I may have made a mistake). When done it should look like this

An algorithm to work out the angle:

> 1. Play turtle, to come up with an estimate (is it more or less than 90°?).
> 2. Try it.
> 3. Ask is it too big or too small.
> 4. Then come up with a new estimate, and try that.
> 5. Keep going until you find the correct value.

An algorithm for choosing the next estimate:

> If you have two values, one that is too big, and one that is too small, then the best guess for the next value is half way between them. After trying it, this new value will ether be too big or too small or just right. If too big or too small, then you have made the problem ½ as big.

import turtle turtle.forward(50) turtle.left(90)

## 1.10. Next

Using only sequences, can get tedious. We have to repeat the instructions, over and over, and if you find a problem, you will have to fix it in many places.

Press back on your browser, and choose the next sheet/page. Also collect a new S.N.O.T. sheet from the tray. Show your progress on the S.N.O.T. sheet.

Next Section - 2. Iteration