pxt-calliope/docs/lessons/rotation-animation/quiz-answers.md

94 lines
1.9 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# rotation animation quiz answers
2016-04-02 01:22:47 +02:00
Learn how to create a rotating image with a while loop.
2016-03-26 00:47:20 +01:00
This is the answer key for the [rotation animation quiz](/microbit/lessons/rotation-animation/quiz).
2016-03-31 00:11:05 +02:00
## 1. What is a " variable"?
2016-03-26 00:47:20 +01:00
2016-03-31 00:11:05 +02:00
Answers may vary. A variable is a place where you can store data so that you can use it later in your code.
2016-03-26 00:47:20 +01:00
2016-03-31 00:11:05 +02:00
## 2. Write the code to create a ** variable** called `foo` that stores a boolean and initialize it to **false**.
2016-03-26 00:47:20 +01:00
2016-03-31 00:11:05 +02:00
```blocks
let rotating = true;
2016-03-26 00:47:20 +01:00
```
2016-03-31 00:11:05 +02:00
## 3. Explain what this line of code does.
2016-03-26 00:47:20 +01:00
2016-03-31 00:11:05 +02:00
```blocks
let rotating = true;
2016-03-26 00:47:20 +01:00
while (rotating) {
2016-03-31 00:11:05 +02:00
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
2016-03-26 00:47:20 +01:00
}
2016-03-31 00:11:05 +02:00
2016-03-26 00:47:20 +01:00
```
2016-03-31 00:11:05 +02:00
2016-03-26 00:47:20 +01:00
<br/>
2016-03-31 00:11:05 +02:00
It is a **while** loop that will be executed only if the ** variable** called `rotating` is **true**.
2016-03-26 00:47:20 +01:00
2016-03-31 00:11:05 +02:00
## 4. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded.
2016-03-26 00:47:20 +01:00
2016-03-31 00:11:05 +02:00
```blocks
2016-03-31 01:10:27 +02:00
basic.showLeds(`
. . # . .
. . # . .
. . # . .
. . # . .
. . # . .
`)
basic.showLeds(`
. . . . .
. . . . .
# # # # #
. . . . .
. . . . .
`)
basic.showLeds(`
. . . . #
. . . # .
. . # . .
. # . . .
# . . . .
`)
basic.showLeds(`
. . . . #
. . . # .
. . # . .
. # . . .
# . . . .
`)
2016-03-26 00:47:20 +01:00
```
2016-03-31 00:11:05 +02:00
2016-03-26 00:47:20 +01:00
![](/static/mb/lessons/rotation-animation-0.png)
![](/static/mb/lessons/rotation-animation-1.png)
![](/static/mb/lessons/rotation-animation-2.png)
![](/static/mb/lessons/rotation-animation-3.png)
Show animation will show a series of image frames on the LED screen, pausing the specified time (400 milliseconds) after each frame