pxt-microbit
Version:
micro:bit target for Microsoft MakeCode (PXT)
39 lines (27 loc) • 1.17 kB
Markdown
Learn to create a random number with input from button A.
Math - Pick Random
* [activity](/lessons/guess-the-number/activity)
* [tutorial](/lessons/guess-the-number/tutorial)
* [challenges](/lessons/guess-the-number/challenges)
* [quiz](/lessons/guess-the-number/quiz)
* [quiz answers](/lessons/guess-the-number/quiz-answers)
Learn how to create numbers randomly by using the input of the @boardname@. 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.
```cards
input.onButtonPressed(Button.A, () => {})
let x = 0
basic.showNumber(0)
randint(0, 3)
basic.clearScreen()
```
* 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