MICROBIT PROJECT
RANDOM NUMBER

separator-blank.png

DESCRIPTION

Students will learn how to display a randomly generated number. 

STEPS

STEP 1
Go to
https://makecode.microbit.org/ and create a new project named RandomNumber.

STEP 2
In the on start block, drag in a show string block (Basic menu). 

STEP 3
Inside the show string block, drag in pick random # to # block (Math menu).  Set the range from 0 to 9.

This block will make the Microbit randomly generate a number from 0 to 9.



STEP 4 (TEST)
Download and run your program.

EXTRA

1. The show string block works differently when it outputs multi-digit numbers versus when it outputs single-digit numbers.  This is why we made the program pick from 0 to 9 to have a consistent output.  Try changing the program to pick from 0 to 100 and see how things differ.

separator-blank.png