Small doc fixes and many tiny edits. (#439)

This commit is contained in:
Galen Nickel
2017-07-06 00:05:42 -07:00
committed by Peli de Halleux
parent edaf2b0403
commit 78d1ce26be
33 changed files with 164 additions and 118 deletions

View File

@ -91,8 +91,8 @@ Because we were able to visualize our blocks as we wrote our pseudocode, we alre
 
* We can now simply add this to our current code
* And provide user feedback by adding some visuals
```block
```blocks
let PlayerBScore = 0
let PlayerAScore = 0
let CoinBHeads = false

View File

@ -299,8 +299,13 @@ This is an example of a board game in which the micro:bit displays an arrow poin
Here is a portion of the board game's code. A boolean variable is used to determine whose turn it is. If player1Turn is false, then it's player 2's turn. A random number is generated to show the arrow seventy-five percent of the time (for values of 0, 1, or 2).
```block
if (player1Turn == true && Math.random(4) < 3) {}
```blocks
input.onGesture(Gesture.Shake, () => {
if (player1Turn == true && Math.random(4) < 3) {
}
})
```
## Assessment
@ -317,8 +322,8 @@ if (player1Turn == true && Math.random(4) < 3) {}
### Micro:bit program
**4 =** micro:bit program:<br/>
`*` Uses Boolean variables in a way that is integral to the program<br/>
`*` Uses a random function in a way that is integral to the program<br/>
`*` Uses Boolean variables in a way that is integral to the program.<br/>
`*` Uses a random function in a way that is integral to the program.<br/>
`*` Compiles and runs as intended<br/>
`*` Meaningful comments in code<br/>
**3 =** micro:bit program lacks 1 of the required element.<br/>

View File

@ -1,4 +1,4 @@
## Unplugged: Two Heads are Better Than One
## Unplugged: Two heads are better than one
Materials: A penny for each student, paper and pencils
 
@ -193,15 +193,15 @@ basic.forever(() => {
})
```
## Random Functions
## Random functions
We use a coin flip to decide things because the result is random, meaning the result happens without any conscious decision or direction. We use dice and game spinners for the same reason. The results are not predetermined or directed in any way.
 
So, how do we get a random flip in code? Most computer programming languages have a built in function that will select a random number given a range of values. Microsoft MakeCode has a block for this. And it also has a block for getting a random true or false value.
 
We will call on this built in function to get a random true or false value for each flip of a coin in the next [Activity](/courses/csintro/booleans/activity).
We will call on this built in function to get a random true or false value for each flip of a coin in the next [activity](/courses/csintro/booleans/activity).
 
Our basic pseudocode for our Double Coin Flipper could look like this:
Our basic pseudocode for our 'double coin flipper' could look like this:
1. Use the random function to get a true/false value for Coin A.
2. Use the random function to get a true/false value for Coin A.