pxt-calliope/docs/reference/js/lessons/rotating-animation/quiz.md

78 lines
2.2 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# rotating animation quiz
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
## Name
## Directions
2016-04-13 17:27:45 +02:00
Use this activity document to guide your work in the [rotating animation tutorial](/js/tutorials/rotating-animation).
2016-03-26 00:47:20 +01:00
Answer the questions below while working on or after you finish the tutorial. Pay attention to the dialogs!
## 1. What is a while loop?
## 2. Consider the following directions
Write the code to create a **global variable** called `rotating` and initialize it to **true**.
## 3. Consider the following directions
Write the code to create a **while** loop that will be executed only if the **global variable** called `rotating` is **true**.
## 4. Consider the following code
```
basic.showAnimation(`
# . . . . . . # . . . . . . # . . . . .
. # . . . . . # . . . . . # . . . . . .
. . # . . . . # . . . . # . . # # # # #
. . . # . . . # . . . # . . . . . . . .
. . . . # . . # . . # . . . . . . . . .
`, 400)
```
If the rectangles below represents a board that is 5 LEDs wide and 5 LEDs tall, place an X approximately where the LED is lighted in the series. Explain why the LED is lighted there.
![](/static/mb/empty-microbit.png)![](/static/mb/empty-microbit.png)![](/static/mb/empty-microbit.png)![](/static/mb/empty-microbit.png)
******************************
## ANSWER KEY
## Directions
Answer the questions below while working on or after you finish the tutorial.
## 2. Consider the following directions
Write the line of code to create a **global variable** called `rotating` and initialize it to **true**.
```
rotating = true
```
## 3. Consider the following directions
Write the line of code that create a **while** loop that will be executed only if the **global variable** called `rotating` is **true**.
```
while (rotating) {
}
```
## 4. Consider the following code
```
basic.showAnimation(`
# . . . . . . # . . . . . . # . . . . .
. # . . . . . # . . . . . # . . . . . .
. . # . . . . # . . . . # . . # # # # #
. . . # . . . # . . . # . . . . . . . .
. . . . # . . # . . # . . . . . . . . .
`, 400)
```
If the rectangles below represents a board that is 5 LEDs wide and 5 LEDs tall, place an X approximately where the LED is lighted in the series. Explain why the LED is lighted there.