Update images and context for v1 UI (#1583)

This commit is contained in:
Galen Nickel 2018-11-04 07:44:54 -08:00 committed by Peli de Halleux
parent f88e967ae8
commit 49cdbb5491
10 changed files with 11 additions and 17 deletions

View File

@ -10,7 +10,7 @@ This activity is based on a very popular phone app invented by Ellen DeGeneres (
* Create a new variable and give it a name like arrayWords.
* Insert a 'set' variable block into the 'on start' block.
* Change the default variable name to this new variable name.
* From the Array Toolbox drawer, drag a 'create array' block to the coding workspace.
* From the Array Toolbox drawer, drag an 'array of' block to the coding workspace.
* Attach this array block to the end of the 'set' variable block.
```blocks
@ -19,13 +19,10 @@ let arrayWords = ["", ""]
Notice that the array comes with 2 string blocks. Well want more for our charades game.
* Click on the blue gear-wheel icon in the top left corner of the 'create array' block.
* From the pop up window, add as many values (elements) as you'd like to the array block by dragging the value block from the left side of the window to the array block on the right side of the window.
* Click on the **(+)** symbol at the end of the 'array of' block.
* Add as many values (elements) as you'd like to the array block by continuing to click on the **(+)**.
* For now, well add 4 more values for a total of 6 values.
![Add values to array](/static/courses/csintro/arrays/array-add-value.png)
* Drag 4 string blocks from the Text Toolbox drawer, and place them in the empty array slots.
```blocks
let arrayWords = ["", "", "", "", "", "", ""]
```
@ -215,18 +212,16 @@ Note that to keep things simple we dont check for duplicates, so its possi
Next, lets create an array with five numbers in it. We will loop through the array and create five separate constellations, using the numbers in the array to represent the number of stars in each of the five constellations.
To create an array, you need to set the value of a variable to the array.
To create an array, you need to set the value of a variable to the array. The Arrays Toolbox has one already made for us.
* From the Variables Toolbox drawer, drag out the set item block and attach a create array with number block to it.
* Then click on the blue Gear icon and add four more values to the block, for a total of five.
* From the Arrays Toolbox drawer, drag out the 'set list to' block that's attached to the array of block containing numbers.
* Then click on the **(+)** symbol to add more values to the block, for a total of five.
![Gear icon on array block](/static/courses/csintro/arrays/gear-values.png)
You can put the Gear view away by clicking on the Gear again. You can drag additional numbers out of the Math category and snap them to the open slots in the Create array with block. Go ahead and change them to some random values, then attach the whole thing to the on start event handler block.
You can drag additional numbers out of the Math category and snap them to the open slots in the Create array with block. Go ahead and change them to some random values, then attach the whole thing to the on start event handler block.
Now, when the micro:bit starts, it will create an array with those five values. Lets create the constellations when the A button is pressed. Looking at our loop, instead of repeating 0 to 4 times, we actually want to use the value from the array to figure out how many stars to create.
* Drag the get value from list block from the Arrays Toolbox drawer and replace the 4 with that block.
* Drag the list get value at block from the Arrays Toolbox drawer and replace the 4 with that block.
You should see that there are more stars printed now, although there is an extra star; if the first value in the array is 5, you will actually see 6 stars because the loop runs when index is 0.
@ -267,9 +262,8 @@ 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++){
}
let list: number[] = []
for (let value of list) {}
```
The following code is useful for printing out the values of the elements in your array:

View File

@ -257,7 +257,7 @@ Challenge question: Can our code be made more efficient?
## Making our code more efficient
Remind students that they can edit the 'if...then' block, adding as many 'else if' conditions as needed.
They can do this by clicking on the blue gear-wheel icon in the top left corner of the 'if...then' block.
They can do this by clicking on the **(+)** or **(-)** symbols on the 'if...then' block.
![Add else-if to if-then block](/static/courses/csintro/radio/if-then-else-if.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 44 KiB