Final edits and image sizing for csintro.
This commit is contained in:
@ -235,7 +235,13 @@ To fix this, we need to do a little math by subtracting 1 from whatever the valu
|
||||
|
||||
**Note:** Be sure to hit Refresh a few times on the simulator, because sometimes some stars get hidden behind other stars.
|
||||
|
||||

|
||||
```block
|
||||
let list = [5, 2, 1, 3, 4]
|
||||
|
||||
for (let index = 0; index < list[0] - 1; index++) {
|
||||
led.plot(Math.random(5), Math.random(5))
|
||||
}
|
||||
```
|
||||
|
||||
The above code takes the first value in the array and creates that many stars at random locations. Now, all we need to do is iterate through the entire array and do the same thing for each of the values. We will put the above code inside another loop that will run the same number of times as the length of the array (in this case, 5). You should also use a 'pause' block and a 'clear screen' block in between each constellation.
|
||||
|
||||
@ -261,11 +267,17 @@ list = [5, 2, 1, 3, 4]
|
||||
|
||||
Traversing an array means proceeding through the elements of the array in sequence. Note that there is a special loop in the Loops Toolbox drawer called ‘for element value of list’. This loop automatically takes each element of your array in turn and copies it into a variable called value.
|
||||
|
||||

|
||||
```block
|
||||
for (let index = 0; index <= 4; index++){
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The following code is useful for printing out the values of the elements in your array:
|
||||
|
||||
```blocks
|
||||
let list = [5, 2, 1, 3, 4]
|
||||
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
for (let value of list) {
|
||||
basic.showNumber(value)
|
||||
@ -279,6 +291,8 @@ However, note that value holds a copy of the element in the array, so changing v
|
||||
If you run the code below, then print out the array again, you will see that it is unchanged.
|
||||
|
||||
```blocks
|
||||
let list = [5, 2, 1, 3, 4]
|
||||
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
for (let value of list) {
|
||||
value += 1
|
||||
|
@ -103,9 +103,9 @@ Have students write a reflection of about 150–300 words, addressing the follow
|
||||
|
||||
### Maker component
|
||||
|
||||
**4 =** Tangible component is tightly integrated with the micro:bit and each relies heavily on the other to make the project complete.
|
||||
**3 =** Tangible component is somewhat integrated with the micro:bit but is not essential.
|
||||
**2 =** Tangible component does not add to the functionality of the program.
|
||||
**4 =** Tangible component is tightly integrated with the micro:bit and each relies heavily on the other to make the project complete.<br/>
|
||||
**3 =** Tangible component is somewhat integrated with the micro:bit but is not essential.<br/>
|
||||
**2 =** Tangible component does not add to the functionality of the program.<br/>
|
||||
**1 =** No tangible component.
|
||||
|
||||
### micro:bit program
|
||||
|
Reference in New Issue
Block a user