# Display number of dots for a given number of cards

Challenge Level: Growing experience

Learning outcomes

Students will be able to:

## Requirement:

Write a program to display numbers 1, 2, 4, 8,... (one at a time) for a given number of cards entered as the input.

## Testing examples:

Your program should display the outputs shown in this table for the given inputs provided.

Input Output
5 1
2
4
8
16
8 1
2
4
8
16
32
64
128
1 1

## Languages

Scratch

#### What it should look like

Click on the green flag, enter the inputs provided in the “testing examples” to see the expected output of your program.

Recommended blocks
set [number of dots v] to [1]

set [number of dots v] to ((number of dots) * (2))

set [number of cards v] to (answer)
when green flag clicked

ask [How many cards would you like to display?] and wait

repeat (number of cards)
end

say (number of dots) for (1) secs
Hints
• Make a variable called “number of cards” to store the number of cards to display entered by the end user as the input (e.g. 5) and a variable called “number of dots” to store the number of dots (e.g. 1, 2, 4, 8, 16) where each number is calculated by multiplying the previous number by 2.

• In this challenge, use the ask [What's your name?] and waitblock to receive an input from the user. Replace the text “What’s your name?” with your own question. The user input will be stored in a predefined variable called “answer” after the check mark button is clicked or the “Enter” key is pressed. You can view the value of “answer” by clicking the checkbox next to the answer block. Set the value of variable “number of cards” to “answer”. Use a repeat loop, repeating the blocks inside (displaying the number of dots) “number of cards” times.

Python

Block-based