Students will be able to:
-
Explain how sequence works in programming.
Computer Science: Programming -
Outline how storing values in a variable is updated because of the code you have used.
Computer Science: Programming
Challenge Level: Beginner
This programming challenge is linked to the following lessons:
Students will be able to:
Write a program to display numbers 1, 2, 4, 8 and 16 on the screen one at a time. This is similar to the previous challenge, but instead of storing a number directly into the variable, you should double the value in the variable each time. You need to use an operator (for multiplying 2 numbers) for this challenge.
The output will always show the numbers 1, 2, 4, 8 and 16 (there is no input).
Click on the green flag to see the expected output of your program.
when flag clicked
set [number of dots v] to [1]
set [number of dots v] to ((number of dots) * (2))
set [number of dots v] to ((number of dots) * (2))
set [number of dots v] to ((number of dots) * (2))
set [number of dots v] to ((number of dots) * (2))
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
set [number of dots v] to [1]
block to set the value of
your new variable.
Use the () * ()
operation under “Operators” to double the value of
your variable.say [Hello] for (2) secs
block with your new
variable.Display the numbers from largest to smallest (display the numbers 16, 8, 4, 2 and 1).