# Getting Better at Repeating

Consider this drawing in pencil code. To program this flower we need to produce 9 "petals" that are the same color, width and general shape, but are pointing outward at different angles from the center. And this time the differences are not random!&#x20;

<img src="https://2507214486-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpUPSf3tCxHePJxNjfg%2Fuploads%2FCycNz60NaCvyIsUeG15I%2Fimage.png?alt=media&#x26;token=f3395620-1c7a-41d5-bed3-025f4397a769" alt="" data-size="original">

Open a new penicl code (be sure to sign in and save) and use this code to create the stem. The last line of code sets the pen color to yellow, but because there is no movement AFTER this, nothing is acually yellow

{% code lineNumbers="true" %}

```
speed 20
pen green
rt 10
fd 200
pen yellow, 10
```

{% endcode %}

![](https://2507214486-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpUPSf3tCxHePJxNjfg%2Fuploads%2FATjGyUaMkFPHZntMc5aC%2Fimage.png?alt=media\&token=be449fcc-8902-4029-93ee-fdb370aa2c29)

Now let us figure out how to draw ONE petal of our flower. Insert this one line of code&#x20;

```
fd 50
```

![](https://2507214486-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpUPSf3tCxHePJxNjfg%2Fuploads%2FvftwrBQZE3IM28lCSBZ4%2Fimage.png?alt=media\&token=4078a574-d3df-47dd-8cf2-75d875ea72c8)

Now - using the turtles ability to move backwards in the same direction it moved forwards, let us get this turtle back to the "center" of our flower. **`Hint`**` ``bk 50`

![](https://2507214486-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpUPSf3tCxHePJxNjfg%2Fuploads%2FoZ1z0kUyfqYiRWFfdAga%2Fimage.png?alt=media\&token=231cdc4d-71fe-494f-a9f4-0d2571982c27)

Now - he needs to TURN and get ready to draw the next flower. Each petal of the flower is an equal distance from all the other petals. This means that each petal is drawn after we have turned the turtle, the same degree, for each one.

![](https://2507214486-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpUPSf3tCxHePJxNjfg%2Fuploads%2FUu91YPBYZFOj0odTk76S%2Fimage.png?alt=media\&token=725a281b-04df-4963-a618-61c122ce5d76)

We are turning in a circle - (which is 360 degrees) and we have 9 petals. So after we draw each petal, we want the turtle to make a right turn that is 360 divided by  9 - so `rt 360 / 9.` **In programing the division sybmol is the forward slash on the bottom row of your keyoard**&#x20;

Here is the code to draw TWO petals

```
fd 50
bk 50
rt 360 / 9
fd 50
bk 50
```

So you could just keep typing that over and over again - OR we can use the ability to REPEAT lines of code and make it easier

**`for petal in [1..9]`**

```
for petal in [1..9]
  move forward 50
  move backwards 50
  make a rt turn
```

Now change your flower to have 12 petals - you will need to change how many times you repeat from 9 to 12 AND change the number of degrees we turn from 360 / 9 to 360 divided by 12. Can you add a center to your flower? Can you add a second, shorter set of petals in a different color?&#x20;

{% embed url="<http://share.pencilcode.net/home/dhkmc-mcgfwrightroom112-fancyFlower>" %}

### Now that you know how to draw a flower using angles and repitition, it is time to be creative. You can decide to stick with flowers OR lose the stems and draw stars or fireworks.

Your Program output should have at least the following:

* [ ] 4 flowers or stars that are purposefully different from each other (not random)
  * [ ] This could include different sizes, different number of petals, centers, MORE than just color
* [ ] At least one other "thing"&#x20;
  * [ ] leaves on the stems of a flower?
  * [ ] a vine?
  * [ ] a shooting star?

![](https://2507214486-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LpUPSf3tCxHePJxNjfg%2Fuploads%2FykFBF6Zl1KDZmd2nzhTJ%2Fimage.png?alt=media\&token=06a88e36-2921-408a-99dc-bacf0a1a6058)

*
