# Display Binary Numbers (using a variable)

Challenge Level: Beginner

Learning outcomes

Students will be able to:

## Requirement:

Write a program to display numbers 1, 2, 4, 8 and 16 on the screen one at a time. Instead of displaying the number directly, you should store it into a variable, and display the variable.

## Testing examples:

The output will always show the numbers 1, 2, 4, 8 and 16 (there is no input).

## Languages

Scratch

#### What it should look like

Click on the green flag to see the expected output of your program.

Recommended blocks
when green flag clicked
set [number of dots v] to [1]

set [number of dots v] to [2]

set [number of dots v] to [4]

set [number of dots v] to [8]

set [number of dots v] to [16]
say (number of dots) for (1) secs

say (number of dots) for (1) secs

say (number of dots) for (1) secs

say (number of dots) for (1) secs

say (number of dots) for (1) secs
Hints
• Make a variable called “number of dots” and change its value by setting it to 1, 2, 4, 8 and 16 respectively. You can find “make a new variable” under the “data” script to create a new variable. Make sure your variable name is meaningful for someone else to read. In the above example, the variable is called "number of dots" because it stores the number of dots on a card.
• Use the set [number of dots v] to [0] block to set the value of your new variable.
• Display the value of your variable on the screen by replacing “Hello” in your say [Hello] for (2) secs block with your variable.
• The number of seconds tells the output how long to show. The script waits that long before continuing.
• Make sure all your blocks are “snapped” together in a line like a jigsaw puzzle.
• Whenever you click the green flag, your script will start. To stop, click the stop button.
Python

Block-based

## Extra Challenge

Display the numbers from largest to smallest (display numbers 16, 8, 4, 2 and 1).