Teachers resources

Introduction

The first lesson in this series about conditionals, 'CONDITIONALS WITH THE WEATHER PREDICTOR', focused on a basic 'if...then...else' logic block. If you have not covered this lesson yet or students had difficulties with it, try covering this material again.

Our second lesson will deal with a more complex if statement. This allows us to test for more than two outcomes. We will do this while playing rock-paper-scissors with the micro:bit. By the end we will have a working game that even keeps score!

Our micro:bit course lessons are tailored to apply knowledge obtained from the Code.org CS Fundamentals. Before students begin these Course Lessons, we encourage students to first complete all CS Fundamentals as a prerequisite. Students should be familiar with conditionals from Code.org CS Fundamentals.

Teacher Guide

Background

Course E. CS Fundamentals. The course begins with a brief review of concepts previously taught in courses C and D. Students will practice coding with algorithms, loops, conditionals, events, and functions.

Conditionals Challenges Assessment

Competency scores: 4, 3, 2, 1

Conditionals Challenges

4 = All three challenges were accomplished
3 = Two challenges were accomplished
2 = One challenge was accomplished
1 = None of the challenges were accomplished OR challenges were tried but unsuccessful

Independent Practice Assessment

Create Your Own micro:bit Die or Dice

4 = Uses an if statement, makes it possible to randomly return 6 outcomes, and has unique outcomes for each number(1-6)
3 = Accomplishes 2 of the three listed in 4
2 = Accomplishes 1 of the three listed in 4
1 = Accomplishes 0 of the three listed in 4 but there was an attempt

Tips on Making Student Presentations Great

It is easiest to use a document camera to demo the student micro:bit programs so that students simply bring their micro:bits to the document camera when presenting. If a document camera is not available, you can have students share their program. Load programs on devices for display by publishing and sharing the URL for the script.

Activity

What you'll need

1 - micro:bit

1 - USB cable

1 - AAA battery pack (optional)

2 - AAA batteries (optional)

Documentation

if (true) {
} else if (false) {
} else {
}

if

Conditionally run code depending on whether a Boolean condition is true or false.

let item = 0
item = 0

setItem

Use an equals sign to make a variable store the number or string you say.

let item = Math.randomRange(0, 10)

random

Return a pseudorandom number between 0 and limit

basic.showIcon(IconNames.Heart)

showIcon

Shows the selected icon on the LED screen

input.onGesture(Gesture.Shake, () => {})

onShake

Start an event handler (part of the program that will run when something happens). This handler works when you do a gesture (like shaking the micro:bit).

The micro:bit shows the icons: rock, paper, or scissors on shake. Shake the micro:bit on the simulator vigorously or press the shake button to trigger the event. You should see an icon displayed after shaking.