Lesson 6 spinner lesson¶
a spin the @boardname@ game with the input on shake.
Topic¶
If (Conditionals)
Quick Links¶
- spinner activity
- spinner challenges
- spinner quiz
- Name
- Directions
- 1. Write the code that stores a random number between 0 and 3 into a local variable named 'random arrow'.
- 2. Write the if statement that will display this down arrow from your code. Hint- This occurs if the local variable 'random arrow' returns 1.
- 3. Write the if statement that will display this right arrow. Hint- This occurs if the local variable 'random arrow' returns 2.
- spinner quiz answers
- Name
- Directions
- 1. Write the code that stores a random number between 0 and 3 into a local variable named 'random arrow'.
- 2. Write the if statement that will display this down arrow from your code. Hint- This occurs if the local variable 'random arrow' returns 1.
- 3. Write the if statement that will display this right arrow. Hint- This occurs if the local variable 'random arrow' returns 2.
Prior learning/place of lesson in scheme of work¶
Learn how to use an if statement to run code run code depending on whether a condition is true or not. We will be learning how to create a die with If statements, On Shake, Variables, Assignment Operator, Pick Random and Show LEDs.
Documentation¶
if (true) {}
let x = 0
input.onGesture(Gesture.Shake, () => {})
Math.randomRange(0, 3)
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
Objectives¶
- learn how to run code when the @boardname@ is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
- learn how to create a local variable as a place where you can store and retrieve data
- learn how the assignment operator is used to declare a new local variable
- learn how to declare a new local variable or update the value of a variable
- learn how to return a random number
- learn how to conditionally run code depending on whether a condition is true or not
- learn how to show an image on the LED screen