132 lines
6.3 KiB
Markdown
132 lines
6.3 KiB
Markdown
# digital pet lesson
|
||
|
||
a display of pet images for the @boardname@.
|
||
|
||
## Topic
|
||
|
||
Functions
|
||
|
||
## Quick Links
|
||
|
||
* [tutorial](/lessons/digital-pet/tutorial)
|
||
* [quiz](/lessons/digital-pet/quiz)
|
||
* [quiz answers](/lessons/digital-pet/quiz-answers)
|
||
* [challenges](/lessons/digital-pet/challenges)
|
||
|
||
## Class
|
||
|
||
Year 7
|
||
|
||
## Prior learning/place of lesson in scheme of work
|
||
|
||
Learn how to create **functions**, `function()` that perform a specific task and returns a result. We will be learning how to create a digital pet app using functions, global variables, forever loop, input button in pressed, input on shake as well as simple commands, such as show string, show number, and pause.
|
||
|
||
## What the teacher needs to know
|
||
|
||
* Algorithm: An unambiguous set of rules or a precise step-bystep guide to solve a problem or achieve a particular objective.
|
||
* Command: An instruction for the computer to execute, written in a particular programming language.
|
||
* Data: A structured set of numbers, possibly representing digitised text, images, sound or video, which can be processed or transmitted by a computer, also used for numerical (quantitative) information.
|
||
* Hardware: The physical systems and components of digital devices; see also software.
|
||
* Input: Data provided to a computer system, such as via a keyboard, mouse, microphone, camera or physical sensors.
|
||
* Output: The information produced by a computer system for its user, typically on a screen, through speakers or on a printer, but possibly through the control of motors in physical systems.
|
||
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
|
||
* 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.
|
||
* Script: A computer program typically executed one line at a time through an interpreter, such as the instructions for a Scratch character.
|
||
* Selection: A programming construct in which one section of code or another is executed depending on whether a particular condition is met.
|
||
* Sequence: To place program instructions in order, with each executed one after the other.
|
||
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
|
||
* Variables: A way in which computer programs can store, retrieve or change data, such as a score, the time left, or the user’s name.
|
||
|
||
**QuickStart Computing Glossary
|
||
|
||
## Documentation
|
||
|
||
* **function** : [read more...](/js/function)
|
||
* **call** : [read more...](/js/call)
|
||
* **global variable** : [read more...](/js/data)
|
||
* **assignment operator** : [read more...](/reference/variables/assign)
|
||
* **forever** : [read more...](/reference/basic/forever)
|
||
* **button is pressed** : [read more...](/reference/input/button-is-pressed)
|
||
* **show string** : [read more...](/reference/basic/show-string)
|
||
* **show number** : [read more...](/reference/basic/show-number)
|
||
* **create image** : [read more...](/reference/images/create-image)
|
||
* **show image** : [read more...](/reference/images/show-image)
|
||
* **pause** : [read more...](/reference/basic/pause)
|
||
|
||
## Resources
|
||
|
||
* Activity: [tutorial](/lessons/digital-pet/tutorial)
|
||
* Activity: [quiz](/lessons/digital-pet/quiz)
|
||
* Extended Activity: [challenges](/lessons/digital-pet/challenges)
|
||
|
||
## Objectives
|
||
|
||
* learn how to create a function as a unit of code that performs a specific task and returns a result
|
||
* learn how to call an existing function in your script
|
||
* learn how to create a global variable as a place where you can store data so that you can use it later in your code, accessible across functions and in nested code blocks
|
||
* learn how to set or change the value of a global variable
|
||
* learn how to repeat code in the background forever
|
||
* learn how to get the state of an input button
|
||
* learn how to show a number on the micro:bit's LED screen
|
||
* learn how to show a string on the micro:bit's LED screen
|
||
* learn how to create an image to show on the micro:bit's LED screen
|
||
* learn how to show an image on the micro:bit's LED screen
|
||
* learn how to pause your code for the specified number of milliseconds
|
||
|
||
## Links to the National Curriculum Programmes of Study for Computing
|
||
|
||
## 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)
|
||
* 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)
|
||
* Uses post-tested loop e.g.‘until’,and a sequence of selection statements in programs,including an if,then and else statement(AL)
|
||
* Understands the difference between, and appropriately uses if and if, then and else statements(AL)
|
||
* Uses a variable and relational operators within a loop to govern termination (AL) (GE)
|
||
* 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
|
||
|
||
* Defines data types: real numbers and Boolean (AB)
|
||
|
||
#### Communication Networks
|
||
|
||
* 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)
|
||
|
||
#### Information Technology
|
||
|
||
* Collects, organizes, 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)
|
||
* Uses criteria to evaluate the quality of solutions, can identify improvements making some refinements to the solution, and future solutions (EV)
|
||
|
||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||
|
||
## Activity
|
||
|
||
* time: 20 min.
|
||
* [tutorial](/lessons/digital-pet/tutorial)
|
||
* [quiz](/lessons/digital-pet/quiz)
|
||
|
||
## Extended Activity
|
||
|
||
* time: 20 min.
|
||
* [challenges](/lessons/digital-pet/challenges)
|
||
|
||
## Homework
|
||
|
||
* Extended Activity: [challenges](/lessons/digital-pet/challenges)
|
||
|
||
## Intended follow on
|
||
|
||
Publish script to the classroom.
|
||
|