move lessons out of web site
will move select lessons back to "educators" section
This commit is contained in:
58
olddocs/lessons/digi-yoyo/activity.md
Normal file
58
olddocs/lessons/digi-yoyo/activity.md
Normal file
@ -0,0 +1,58 @@
|
||||
# digi yoyo activity
|
||||
|
||||
Create a counter with a while loop.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Welcome! This tutorial will teach how to create a counter with a while loop. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
Create a variable that acts as a counter and set it to 0.
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
```
|
||||
|
||||
Add a while loop that will loop over and over until the variable `count` equals 10.
|
||||
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
while (count < 10) {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Let's add a pause. Then show the value of the the count.
|
||||
|
||||
|
||||
```blocks
|
||||
let count = 0;
|
||||
while (count < 10) {
|
||||
basic.pause(100);
|
||||
basic.showNumber(count)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Increase the value of count by one.
|
||||
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
while (count < 10) {
|
||||
basic.pause(100)
|
||||
basic.showNumber(count)
|
||||
count = count + (count - 1)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/lessons/digi-yoyo/challenges)!
|
||||
|
||||
### ~
|
||||
|
73
olddocs/lessons/digi-yoyo/challenges.md
Normal file
73
olddocs/lessons/digi-yoyo/challenges.md
Normal file
@ -0,0 +1,73 @@
|
||||
# digi yoyo challenges
|
||||
|
||||
Coding challenges for the digi yoyo.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following [guided tutorial](/lessons/digi-yoyo/activity), your code should look like this:
|
||||
|
||||
|
||||
```blocks
|
||||
let count = 0;
|
||||
while (count < 10) {
|
||||
basic.pause(100);
|
||||
basic.showNumber(count);
|
||||
count = count + 1;
|
||||
basic.pause(20);
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
How about we create a counter that counts backwards from 10 to 1? Let's add a while loop that executes only when `count` is greater than 0.
|
||||
|
||||
|
||||
```blocks
|
||||
let count = 0;
|
||||
while (count < 10) {
|
||||
basic.pause(100);
|
||||
basic.showNumber(count);
|
||||
count = count + 1;
|
||||
basic.pause(20);
|
||||
}
|
||||
while (count > 0) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Inside of the while loop, let's add `pause->(1000)` so that we have a pause between each number as it's counting down. Also, let's show `count`!
|
||||
|
||||
|
||||
|
||||
```blocks
|
||||
let count = 0;
|
||||
while (count < 10) {
|
||||
basic.pause(100);
|
||||
basic.showNumber(count);
|
||||
count = count + 1;
|
||||
}
|
||||
while (count > 0) {
|
||||
basic.pause(100);
|
||||
basic.showNumber(count);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now, we need `count` to decrease by one after the micro:bit has displayed the value of `count`.
|
||||
|
||||
We can do this by adding this line:
|
||||
|
||||
```blocks
|
||||
let count = 0;
|
||||
count = count + (count - 1);
|
||||
|
||||
```
|
35
olddocs/lessons/digi-yoyo/quiz-answers.md
Normal file
35
olddocs/lessons/digi-yoyo/quiz-answers.md
Normal file
@ -0,0 +1,35 @@
|
||||
# digi yoyo quiz answers
|
||||
|
||||
Answers for digi yoyo quiz.
|
||||
|
||||
This is the answer key for the [digi yoyo quiz](/lessons/digi-yoyo/quiz).
|
||||
|
||||
## 1. Describe what a "while loop" does?
|
||||
|
||||
<br/>
|
||||
|
||||
A loop that repeats code while a condition is true.
|
||||
|
||||
## 2. Write the code that will create a **variable** called `count` and set the variable to 0.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
```
|
||||
|
||||
## 3. Create a `while loop` that will loop until the **variable** `count` equals 4.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
while (count < 5) {
|
||||
count = count + 1
|
||||
}
|
||||
```
|
||||
|
28
olddocs/lessons/digi-yoyo/quiz.md
Normal file
28
olddocs/lessons/digi-yoyo/quiz.md
Normal file
@ -0,0 +1,28 @@
|
||||
# digi yoyo quiz
|
||||
|
||||
Create a counter with a while loop
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [digi yoyo tutorial](/lessons/digi-yoyo/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what a "while loop" does?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the code that will create a variable called count and set the variable to 0.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the code for a while loop that will loop until the variable count equals 4.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
Reference in New Issue
Block a user