pxt-calliope/docs/lessons/guess-the-number.md
2016-04-01 16:22:47 -07:00

50 lines
1.2 KiB
Markdown

# guess the number lesson
Learn to create a random number with input from button A.
### @video td/videos/guess-the-number-0
## Topic
Math - Pick Random
## Quick links
* [activity](/microbit/lessons/guess-the-number/activity)
* [challenges](/microbit/lessons/guess-the-number/challenges)
* [quiz](/microbit/lessons/guess-the-number/quiz)
* [quiz answers](/microbit/lessons/guess-the-number/quiz-answers)
## Prior learning/place of lesson in scheme of work
Learn how to create numbers randomly by using the input of the BBC micro:bit. We will be learning how to create random numbers with input using a local variable as well as simple commands, such as pick number and show number.
## Documentation
```docs
input.onButtonPressed(Button.A, () => {
})
let x = 0
basic.showNumber(0)
Math.random(3)
basic.clearScreen()
```
## Objectives
* learn how to run code when an input button is pressed
* learn how a variable is a place where you can store data
* learn how to set the value of a local variable
* learn how to returns a random number
* learn how to show a number on the LED screen, one digit at a time (scrolling left to right)
* learn how to turn off all the LED lights on the LED screen