8. For Loops
Complete the following tasks using for loops.
8.1 Random Movements
Instructions
Generate 5 random numbers between 1 and 4 (inclusive). Make the Edison perform a different movement / action based on the generated number:
| Random Number | Movement / Action |
|---|---|
| 1 | Move forwards 10cm |
| 2 | Move backwards 10cm |
| 3 | Spin left |
| 4 | Spin right |
8.2 Random Guessing
Instructions
Make a number guessing game. Generate a number between 1 and 10. Use the triangle and round buttons for input.
- The Edison will generate a random number between
1and10. - The user will press the
trianglebutton a number of times to guess the number. - Pressing the
roundbutton will end their guess. - If the user is
correct, beep the Edisontwice. - If the user is
incorrect, beep the Edisononce.
8.3 Random Beeping
Instructions
Using the code you wrote from the previous task, use Ed.PlayMyBeep(8000) to beep the amount of times of the randomly generated number. You must use a for loop for this.