move lessons out of web site
will move select lessons back to "educators" section
This commit is contained in:
@ -1,36 +0,0 @@
|
||||
# looper blocks activity
|
||||
|
||||
Welcome! This activity will teach how to display a series of numbers for a for loop. Let's get started!
|
||||
|
||||
Let's create a for loop where `0` is the loop's starting value, `i` is the index variable, and `5` is the ending value. The index variable `i` starts at 0 and increases by 1 each time through the loop. The loop ends when `i = 5`.
|
||||
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 6; i++) {
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
We will show the number of times the loop has been executed. It will go from zero to five times.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 6; i++) {
|
||||
basic.showNumber(i)
|
||||
}
|
||||
```
|
||||
|
||||
The for loop while cycle through to six immediately unless we pause for a little bit in between each loop.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 6; i++) {
|
||||
basic.showNumber(i)
|
||||
basic.pause(2000)
|
||||
}
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/lessons/looper/challenges)!
|
||||
|
||||
### ~
|
||||
|
@ -1,85 +0,0 @@
|
||||
# looper block challenges
|
||||
|
||||
Coding challenges for the looper.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided activity:
|
||||
|
||||
* [activity](/lessons/looper/activity)
|
||||
|
||||
At the end of the activity, your code should look like this:
|
||||
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 6; i++) {
|
||||
basic.showNumber(i)
|
||||
basic.pause(2000)
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
What if we want to count up to lucky number 7 instead? Let's do that by changing the ending value to `7` instead of `5`.
|
||||
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 8; i++) {
|
||||
basic.showNumber(i)
|
||||
basic.pause(2000)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
* Run the program now to see your changes.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
What about 9? Let's do that by changing the ending value to `9`.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 10; i++) {
|
||||
basic.showNumber(i)
|
||||
basic.pause(2000)
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
* Run your code to see the new counter.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now let's start counting from `3` instead! Our for loop will always start at `0` so we simply add `3` to the `i` variable when passing it to `show number`.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 10; i++) {
|
||||
basic.showNumber(i+3)
|
||||
basic.pause(2000)
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
Run it on the simulator!
|
||||
|
||||
### Challenge 4
|
||||
|
||||
Now, let's **count down from 9**. Change the line `show number(i + 2, 150)` to `show number(9 - i, 150)`.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 10; i++) {
|
||||
basic.showNumber(9-i)
|
||||
basic.pause(2000)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
* Run the code to make sure it is doing what is expected.
|
||||
|
||||
### Challenge 5
|
||||
|
||||
After counting down from `9` let's show the string `BOOOM`!
|
||||
|
@ -1,40 +0,0 @@
|
||||
# looper quiz answers
|
||||
|
||||
Learn how to create a series of numbers with a for loop.
|
||||
|
||||
This is the answer key for the [looper quiz](/lessons/looper/quiz).
|
||||
|
||||
## 1. What is a for loop?
|
||||
|
||||
Answers will vary. In general, for loop refers to the code that repeats for a fixed number of times. We specify the LED using x, y coordinates.
|
||||
|
||||
## 2. Consider the following code
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 4; i++) {
|
||||
basic.showNumber(i, 150)
|
||||
}
|
||||
```
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded.
|
||||
|
||||
Let's create a for loop where `0` is the loop's starting value, `i` is the index variable, and `4` is the ending value. The index variable `i` starts at 0 and increases by 1 each time through the loop. The loop ends when `i = 4`.
|
||||
|
||||

|
||||
|
||||
## 3. Consider the following code
|
||||
|
||||
```blocks
|
||||
for (let i1 = 0; i1 < 6; i1++) {
|
||||
basic.showNumber(i1, 150)
|
||||
}
|
||||
```
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded.
|
||||
|
||||
Let's create a for loop where `0` is the loop's starting value, `i` is the index variable, and `6` is the ending value. The index variable `i` starts at 0 and increases by 1 each time through the loop. The loop ends when `i = 6`.
|
||||
|
||||

|
||||
|
||||

|
||||
|
@ -1,42 +0,0 @@
|
||||
# looper quiz
|
||||
|
||||
Learn how to create a series of numbers with a for loop.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [looper tutorial](/lessons/looper/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what a "for loop" does?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Draw the areas where the LEDs will be lit based on the code below. Explain why you chose to draw those numbers.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 4; i++) {
|
||||
basic.showNumber(i, 150)
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Draw the areas where the LEDs will be lit based on the code below. Explain why you chose to draw those numbers.
|
||||
|
||||
```blocks
|
||||
for (let i1 = 0; i1 < 6; i1++) {
|
||||
basic.showNumber(i1, 150)
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||

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