Migrate docs from the other repo
This commit is contained in:
44
docs/reference/js/lessons/guess-the-number/activity.md
Normal file
44
docs/reference/js/lessons/guess-the-number/activity.md
Normal file
@ -0,0 +1,44 @@
|
||||
# guess the number activity
|
||||
|
||||
guess the number with math random. #microbit #docs
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/guess-the-number-0
|
||||
|
||||
Welcome! This tutorial will help you create a guess the number game! Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
To create a new script, go to the [Create Code](/microbit/create-code) page and tap New Project under **Touch Develop**.
|
||||
|
||||
Add an event handler when button `A` is pressed.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
})
|
||||
```
|
||||
|
||||
Create a local variable of type number `x` and set it to a random number using `math->random`. `math->random(10)` generates a random number between `0` and `10` **excluded**.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
let x = Math.random(10)
|
||||
})
|
||||
```
|
||||
|
||||
Show the random number on the screen.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
let x1 = Math.random(10)
|
||||
basic.showNumber(x1, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/guess-the-number/challenges)!
|
||||
|
||||
### ~
|
||||
|
39
docs/reference/js/lessons/guess-the-number/challenges.md
Normal file
39
docs/reference/js/lessons/guess-the-number/challenges.md
Normal file
@ -0,0 +1,39 @@
|
||||
# guess the number challenges
|
||||
|
||||
Coding challenges for the guess the number tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/guess-the-number/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
let x = Math.random(10)
|
||||
basic.showNumber(x, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
### @video td/videos/guess-the-number-2
|
||||
|
||||
When button `B` is pressed, we want to clear the screen. This will make it so users can play your game over and over again! Add an event handler to handle this case.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
let x1 = Math.random(10)
|
||||
basic.showNumber(x1, 150)
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
basic.clearScreen() // ***
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Show an animation when you clear the screen! Choose what animation makes most sense to you. Be creative!
|
||||
|
99
docs/reference/js/lessons/guess-the-number/lesson-plan.md
Normal file
99
docs/reference/js/lessons/guess-the-number/lesson-plan.md
Normal file
@ -0,0 +1,99 @@
|
||||
# guess the number lesson plan
|
||||
|
||||
Learn how to create a random number with input from button A. #input #screen #math #docs
|
||||
|
||||
### @video vimeo/134121077
|
||||
|
||||
## Topic
|
||||
|
||||
Input - Random Numbers
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to create numbers randomly by using the input of the BBC micro:bit. We will be learning how to create random numbers with input using a local variable as well as simple commands, such as math->random, and show number.
|
||||
|
||||
## What the teacher needs to know
|
||||
|
||||
**Program:** A stored set of instructions encoded in a language understood by the computer that does some form of computation, processing input and/or stored data to generate output.**
|
||||
|
||||
**Algorithm:** An unambiguous set of rules or a precise step-by-step guide to solve a problem or achieve a particular objective. The guided tutorial follows a algorithm and is a precise step-by-step guide to solve a problem**
|
||||
|
||||
**Loop:** A block of code repeated automatically under the program’s control. ** The blink program introduces Forever. Forever will repeats code in the background forever.
|
||||
|
||||
**Command:** An instruction for the computer to execute, written in a particular programming language.**
|
||||
|
||||
**QuickStart Computing Glossary
|
||||
|
||||
## Documentation
|
||||
|
||||
* **local variables**: [read more...](/microbit/reference/variables/var)
|
||||
* **math**: [read more...](/microbit/js/math)
|
||||
* **on button pressed**: [read more...](/microbit/reference/input/on-button-pressed)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/guess-the-number/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/guess-the-number/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/guess-the-number/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a global variable
|
||||
* learn how a rotating animation
|
||||
* learn how to repeat the animation
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Assessment
|
||||
|
||||
### Progression Pathways
|
||||
|
||||
### Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Understands that iteration is the repetition of a process such as a loop. (AL)
|
||||
* 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)
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Understands the difference between data and information. (AB)
|
||||
* Defines data types: real numbers and Boolean. (AB)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organises and presents data and information in digital content. (AB)
|
||||
* Makes appropriate improvements to solutions based on feedback received, and can comment on the success of the solution. (EV)
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/guess-the-number/tutorial)
|
||||
* [quiz](/microbit/lessons/guess-the-number/quiz)
|
||||
* assessment opportunities: forever, plot, pause, clear screen
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/guess-the-number/challenges)
|
||||
* assessment opportunities: loops, plot, pause, clear screen
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/guess-the-number/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
39
docs/reference/js/lessons/guess-the-number/quiz-answers.md
Normal file
39
docs/reference/js/lessons/guess-the-number/quiz-answers.md
Normal file
@ -0,0 +1,39 @@
|
||||
# guess the number quiz answers
|
||||
|
||||
Learn how to generate a random number on the micro:bit. #math #random #docs
|
||||
|
||||
This is the answer key for the [guess the number quiz](/microbit/lessons/guess-the-number/quiz).
|
||||
|
||||
## 1. What is on button pressed?
|
||||
|
||||
Answers may vary. Generally, on button pressed run code when an input button is pressed. The micro:bit has two input buttons: A and B.
|
||||
|
||||
## 2. Consider the following directions
|
||||
|
||||
Write the line of code that creates a condition when the BBC micro:bit button A is pressed.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
})
|
||||
```
|
||||
|
||||
## 3. Consider the following directions
|
||||
|
||||
Write the line of code that creates a **local variable** and a **random number**.
|
||||
|
||||
```
|
||||
let randomNumber = Math.random(10)
|
||||
```
|
||||
|
||||
## 4. Consider the following code
|
||||
|
||||
```
|
||||
randomNumber = Math.random(10)
|
||||
```
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded.
|
||||
|
||||

|
||||
|
||||
The random number generator will return a number from 0 to the limit. However, not including the limit unless the limit is 0. So you can place an X to represent any single digit number.
|
||||
|
35
docs/reference/js/lessons/guess-the-number/quiz.md
Normal file
35
docs/reference/js/lessons/guess-the-number/quiz.md
Normal file
@ -0,0 +1,35 @@
|
||||
# guess the number quiz
|
||||
|
||||
Learn how to generate a random number on the micro:bit. #math #random #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [guess the number tutorial](/microbit/lessons/guess-the-number/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what "input -> on button pressed" does?
|
||||
|
||||
<br />
|
||||
|
||||
## 2. Write the line of code that creates a condition for on button A pressed.
|
||||
|
||||
<br />
|
||||
|
||||
## 3. Write the line of code that creates a `local variable` called `randomNumber` and will return a number from 0 to a limit of 10.
|
||||
|
||||
<br />
|
||||
|
||||
## 4. Draw the area that could be lit based on the code below. Explain why you chose to draw that number.
|
||||
|
||||
```
|
||||
let randomNumber = Math.random(10)
|
||||
basic.showNumber(randomNumber, 150)
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
Reference in New Issue
Block a user