moving out outdated js docs
This commit is contained in:
87
olddocs/js/lessons/flipping-bird/challenges.md
Normal file
87
olddocs/js/lessons/flipping-bird/challenges.md
Normal file
@ -0,0 +1,87 @@
|
||||
# flipping bird challenges
|
||||
|
||||
Coding challenges for flipping bird. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/lessons/flipping-bird/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
counter = counter + 1
|
||||
if (math.mod(counter, 2) == 1) {
|
||||
basic.plotImage(`
|
||||
# # . # #
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
We handled the case of when `math->mod(counter,2) = 1`. We haven't done anything when the remainder is 0! Add an if statement to handle this case.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
counter = counter + 1
|
||||
if (math.mod(counter, 2) == 1) {
|
||||
basic.plotImage(`
|
||||
# # . # #
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
if (math.mod(counter, 2) == 0) {
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/flipping-bird-2
|
||||
|
||||
Inside of that `if` statement you created in challenge 1, add `basic->plot image()` and display an upside down flying bird.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
counter = counter + 1
|
||||
if (math.mod(counter, 2) == 1) {
|
||||
basic.plotImage(`
|
||||
# # . # #
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
if (math.mod(counter, 2) == 0) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
# # . # #
|
||||
`) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
* `Run` the code to see if it works as expected.
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
Display a check mark and question mark instead of flipping birds. Or better yet, come up with your own pair of opposites to display!
|
||||
|
50
olddocs/js/lessons/flipping-bird/quiz-answers.md
Normal file
50
olddocs/js/lessons/flipping-bird/quiz-answers.md
Normal file
@ -0,0 +1,50 @@
|
||||
# flipping bird quiz answers
|
||||
|
||||
use modulo with a conditional.
|
||||
|
||||
This is the answer key for the [flipping bird quiz](/lessons/flipping-bird/quiz).
|
||||
|
||||
## 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/>
|
||||
|
||||

|
||||
|
||||
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/>
|
||||
|
||||

|
||||
|
||||
The display will show `2` because the remainder of 12 divided by 5 is 2.
|
||||
|
60
olddocs/js/lessons/flipping-bird/quiz.md
Normal file
60
olddocs/js/lessons/flipping-bird/quiz.md
Normal file
@ -0,0 +1,60 @@
|
||||
# flipping bird quiz
|
||||
|
||||
use modulo with a conditional.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [flipping bird tutorial](/lessons/flipping-bird/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What does "modulo" mean in math?
|
||||
|
||||
## 2. Consider the following directions
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade in the LEDs that show the value being stored into the **global variable**, `count`.
|
||||
|
||||
```
|
||||
count = 1
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. 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/>
|
||||
|
||||
## 4. 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/>
|
||||
|
Reference in New Issue
Block a user