# die roll lesson

create a die on the BBC micro:bit #button #pressed #math #random #var #string #if #docs

## Topic

If (Conditionals)

## Quick Links

* [activity](/microbit/lessons/die-roll/activity)
* [challenges](/microbit/lessons/die-roll/challenges)
* [quiz](/microbit/lessons/die-roll/quiz)
* [quiz answers](/microbit/lessons/die-roll/quiz-answers)
* [tutorial](/microbit/lessons/die-roll/tutorial)

## Class

Year 7

## Prior learning/place of lesson in scheme of work

Learn how to use an if statements 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

* **Variables** : [read more...](/microbit/reference/variables/var)
* **If** : [read more...](/microbit/reference/logic/if)
* **On Shake** : [read more...](/microbit/reference/input/on-gesture)
* **Assignment Operator** : [read more...](/microbit/reference/variables/assign)
* **Math Random** : [read more...](/microbit/js/math)
* **Show LEDs** : [read more...](/microbit/reference/basic/show-leds)

## Objectives

* learn how to run code when the BBC micro:bit 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

## Progression Pathways / Computational Thinking Framework

#### Algorithms

* Designs solutions (algorithms) that use repetition and two-way  selection, ie if, then and else.(AL)
* Uses diagrams to express solutions.(AB)
*  Uses logical reasoning to predict  outputs, showing an awareness of inputs (AL)
*  Designs solutions  by decomposing a problem and creates a sub-solution for each of these parts. (DE) (AL) (AB)
* Represents solutions using a structured notation (AL) (AB)

#### Programming & Development

* Creates programs that implement algorithms to achieve given goals (AL)
*  Declares and assigns variables(AB)
* Understands the difference between, and appropriately uses if and if, then and else statements(AL)
* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL)
* Selects the appropriate data types(AL) (AB

#### Data & Data Representation

* Understands the difference between data and information(AB)
* Uses filters or can perform single criteria searches for information.(AL)
* Performs more complex searches for information e.g. using Boolean and relational operators(AL) (GE) (EV)
* Defines data types: real numbers and Boolean (AB)

#### Hardware & Processing

* Knows that computers collect data from various input devices, including sensors and application software (AB)
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)

Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation

## Activity

* time: 20 min.
* [activity](/microbit/lessons/die-roll/activity)
* [tutorial](/microbit/lessons/die-roll/tutorial)
* [quiz](/microbit/lessons/die-roll/quiz)

## Extended Activity

* time: 20 min.
* [challenges](/microbit/lessons/die-roll/challenges)

## Homework

* Extended Activity: [challenges](/microbit/lessons/die-roll/challenges)

