pxt-calliope/docs/lessons/speed-button/quiz-answers.md

51 lines
1.3 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# speed button quiz answers
2016-04-02 01:22:47 +02:00
counter that keeps track of how many times button "A" has been pressed.
2016-03-26 00:47:20 +01:00
2016-04-13 17:27:45 +02:00
This is the answer key for the [speed button quiz](/lessons/speed-button/quiz).
2016-03-26 00:47:20 +01:00
## 1. What is a variable?
<br/>
A variable that is available throughout your main function.
## 2. If the rectangle below represents the @boardname@, shade the area that shows the value of the variable count.
2016-03-26 00:47:20 +01:00
2016-03-31 01:43:56 +02:00
```blocks
2016-03-26 00:47:20 +01:00
let count = 0
```
![](/static/mb/lessons/speed-button-0.png)
## 3. If the rectangle below represents the @boardname@, shade the areas that will be displayed after two button presses on Button A. Explain why that particular area is shaded.
2016-03-26 00:47:20 +01:00
2016-03-31 01:43:56 +02:00
```blocks
2016-07-19 12:42:42 +02:00
let count = 0
input.onButtonPressed(Button.A, () => {
2016-07-19 12:42:42 +02:00
count = count + 1
basic.showNumber(count, 100)
2016-03-26 00:47:20 +01:00
})
```
<br/>
![](/static/mb/lessons/speed-button-1.png)
After two button presses, **count** will be equal to 2.
## 5. If the rectangle below represents the @boardname@, shade the areas that will be displayed after five button presses on Button A. Explain why that particular area is shaded.
2016-03-26 00:47:20 +01:00
2016-03-31 01:43:56 +02:00
```blocks
2016-07-19 12:42:42 +02:00
let count = 0
input.onButtonPressed(Button.A, () => {
2016-07-19 12:42:42 +02:00
count = count + 1
basic.showNumber(count, 100)
2016-03-26 00:47:20 +01:00
})
```
![](/static/mb/lessons/speed-button-2.png)
After five button presses, **count** will be equal to 5.