pxt-calliope/docs/reference/js/lessons/flipping-bird/quiz-answers.md

51 lines
1.1 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# flipping bird quiz answers
2016-04-02 01:22:47 +02:00
use modulo with a conditional.
2016-03-26 00:47:20 +01:00
2016-04-13 17:27:45 +02:00
This is the answer key for the [flipping bird quiz](/lessons/flipping-bird/quiz).
2016-03-26 00:47:20 +01:00
## 1. What does "modulo" mean in math?
<br/>
Modulo (or Mod) is the remainder of a division problem.
## 2. Consider the following code
If the rectangle below represents the BBC micro:bit, shade in the LEDs that show the value being stored into the **global variable**, `count`. Explain why that particular area is shaded.
```
count = 1
count_ = count_ + 2
```
<br/>
<br/>
![](/static/mb/lessons/flipping-bird-0.png)
The variable `count` is now equal to 3.
<br/>
## 3. Consider the following directions
Modulo (Mod) tells us what the remainder of a division is. For example, `15 mod 4 is 3` since 15 divided by 4 has a remainder of 3.
```
count = 12
count = math.mod(count, 5)
```
If the rectangle below represents the BBC micro:bit, shade in the LEDs that show the value being stored into the **global variable**, `count`. Explain why that particular area is shaded.
<br/>
<br/>
![](/static/mb/lessons/flipping-bird-1.png)
The display will show `2` because the remainder of 12 divided by 5 is 2.