Lesson 5 truth or dare lesson¶
create a love meter with the @boardname@.
Topic¶
If (Conditionals)
Quick Links¶
- truth or dare activity
- truth or dare challenges
- truth or dare quiz
- Name
- Directions
- 1. Write the code that will randomly return 0 through 3 and stores the value inside a local variable called 'random'.
- 2. Write an if statement that will display the message "TRUTH" on the @boardname@ if the local variable 'random' equals 0.
- 3. If the local variable 'random' equals 1, write the string that will be displayed.
- 4.Write the code that will display this up arrow after pressing button "A".
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 the game truth or dare using input an if statement, a local variable, math random as well as simple commands, such as show string and show LEDs.
Documentation¶
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
input.onButtonPressed(Button.A, () => {})
let x = 0
Math.randomRange(0, 3)
if (true) {}
basic.showString("Hello!")
Objectives¶
- learn how to display an image on the @boardname@
- learn how to run code when an input button is pressed
- learn how to a create a variable for a place where you can store and retrieve data
- 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 a string on the LED screen one character at a time (scrolling from left to right)