moving stuff around

This commit is contained in:
Tom Ball 2016-06-14 21:37:55 -04:00
parent 2c399f198a
commit bbbb1ea6bc
8 changed files with 28 additions and 17 deletions

View File

@ -3,5 +3,4 @@
```cards ```cards
for(let i = 0;i<5;i++) {} for(let i = 0;i<5;i++) {}
while(true) {} while(true) {}
basic.forever(() => {})
``` ```

View File

@ -4,7 +4,7 @@
Are you ready to build cool BBC micro:bit programs? Are you ready to build cool BBC micro:bit programs?
Here are some challenges for you. Unscramble the blocks in the editor Here are some challenges for you. Arrange the blocks in the editor
to make real programs that work! to make real programs that work!
## ~ ## ~
@ -12,7 +12,7 @@ to make real programs that work!
### Happy face ### Happy face
There are three blocks in the editor (the area to the left). There are three blocks in the editor (the area to the left).
They should look like this: Arrange them to look like this:
```blocks ```blocks
basic.forever(() => { basic.forever(() => {

View File

@ -65,5 +65,3 @@
### ~ ### ~
### @section full ### @section full
The lessons promote computational thinking and computer science literacy.

View File

@ -1,4 +1,4 @@
# Microb:bit APIs # Micro:bit APIs
```namespaces ```namespaces
basic.showNumber(0); basic.showNumber(0);

View File

@ -5,7 +5,7 @@ The following built-in types are supported for the BBC micro:bit:
* **[String](/reference/types/string)**: a sequence of characters * **[String](/reference/types/string)**: a sequence of characters
* **[Number](/reference/types/number)**: an integer number (32-bit signed) * **[Number](/reference/types/number)**: an integer number (32-bit signed)
* **[Boolean](/reference/types/boolean)**: true or false * **[Boolean](/blocks/logic/boolean)**: true or false
* **[Image](/blocks/image)**: a collection of [micro:bit LED states](/device/screen) (on/off) * **[Image](/blocks/image)**: a collection of [micro:bit LED states](/device/screen) (on/off)
TypeScript allows you to create user-defined classes of data. TypeScript allows you to create user-defined classes of data.

View File

@ -8,9 +8,12 @@ A *Number* is an integer such as `42` or `-42`. More precisely, a *Number* is a
### Declare a number variable ### Declare a number variable
Use the [var statement](/reference/variables/var) and the [assignment operator](/reference/variables/assign) declare a *local* number variable. Like this: You can assign a number to a variable:
![](/static/mb/blocks/number-0.png) ```blocks
let num = 42;
basic.showNumber(42);
```
### Arithmetic operators ### Arithmetic operators
@ -20,7 +23,7 @@ The following arithmetic operators work on numbers and return a [Number](/refere
* subtraction: `1 - 3 ` * subtraction: `1 - 3 `
* multiplication: `3 * 2` * multiplication: `3 * 2`
* integer division: `7 / 3` * integer division: `7 / 3`
* modulo is available through the [math library](/reference/math) * modulo is available through the [math library](/blocks/math)
### Relational operators ### Relational operators
@ -35,23 +38,34 @@ The following relational operators work on numbers and return a [Boolean](/refer
### Show number ### Show number
The [show number](/reference/basic/show-number) function displays a number on the [LED screen](/device/screen). For example, this code displays the number 42: The [show number](/reference/basic/show-number) function displays a number on the [LED screen](/device/screen).
For example, this code displays the number 42:
![](/static/mb/blocks/number-1.png) ```blocks
basic.showNumber(42);
```
### Functions that return a number ### Functions that return a number
Some functions return a number, which you can store in a variable. For example the following code gets the display brightness (using the [brightness function](/reference/led/brightness)) and stores the value in a variable named `brightness`: Some functions return a number, which you can store in a variable.
For example the following code gets the display brightness
(using the [brightness function](/reference/led/brightness)) and stores the value in a variable named `brightness`:
![](/static/mb/blocks/number-2.png) ```blocks
let brightness = led.brightness()
```
### Math functions ### Math functions
The [math library](/reference/math) includes math related functions. In the [Block Editor](/blocks/editor), click `math` on the Code Keyboard to see the math functions. For example, the `absolute` function returns the returns the absolute value of input parameter `x`: The [math library](/reference/math) includes math related functions.
For example, the `absolute` function returns the returns the absolute value of input parameter `x`:
![](/static/mb/blocks/number-3.png) ```blocks
let abs = math.absolute(-42);
basic.showNumber(abs);
```
### See also ### See also
[math library](/reference/math), [var](/reference/variables/var), [Boolean](/reference/types/boolean), [show number](/reference/basic/show-number) [math](/blocks/math), [var](/blocks/variables/var), [Boolean](/reference/types/boolean), [show number](/reference/basic/show-number)