> For the complete documentation index, see [llms.txt](https://computational-thinking-in-room11.gitbook.io/room-112-dhs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://computational-thinking-in-room11.gitbook.io/room-112-dhs/text-based-programming/random-and-repetition-good-clean-fun.md).

# Random & Repetition: Good Clean Fun

So far all the code you have written has been sequential, one line of code  for each action. But sometimes we want the computer to repeat an action and for that we will use a for loop

```
Random Walk (I love this program but it has zero actual uses)

for number in [1..20]     this means count from 1 to 20 and each time do
    fd 10                 make sure this is INDENTED
    rt random(91)
    dot limegreen, 6

```

How many dots will  this program draw?  Now change the program to make 50 dots

Each time, the program is selecting a random number between 1 and 91 as the angle of the right turn

Now modify your program so that it picks a random color each time.Make sure to  include this code BEFORE you tell the computer to draw the dot.&#x20;

```
aColor = random [red,blue,yellow,green]
dot aColor, 6
```

**TIP**: Spaces  matter  here

![20th century art movement where perspective was replaced with an emphasis on geometric shapes](https://2507214486-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpUPSf3tCxHePJxNjfg%2F-LzrGmJZGGDBrbOa0umy%2F-LzrGtJoWNMW6D1WSiCL%2Fimage.png?alt=media\&token=1b49c072-80c8-4c4c-b76d-1b72e010e015)

```
for line in [1..40]
    pen  random [red, black, blue, yellow]
    fd random 70
    rt 120
```

In Network Notebook: explain in english the steps that the computer is taking for each line.

Now modify the code so that the lines can be longer  and modify the angle so that your drawing is based on a pentagon
