0% found this document useful (0 votes)
4 views

Educator guide - Unit 2 Algorithms

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Educator guide - Unit 2 Algorithms

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Introduction to Computer

Science

Unit 2:
Algorithms

Educator guide
makecode.microbit.org

Introduction to Computer Science Unit 2: Algorithms | 1


Table of Contents
Overview....................................................................................................................................................... 3
Unit summary............................................................................................................................................. 3
Lessons....................................................................................................................................................... 3
Learning goals............................................................................................................................................ 3
CSTA K-12 computer science standards..................................................................................................... 3
Required educator preparation...................................................................................................................... 4
Preparing to lead the unit........................................................................................................................... 4
Required skills............................................................................................................................................ 4
Recommended resources........................................................................................................................... 4
Lesson A: How computers function................................................................................................................ 5
Lesson plan................................................................................................................................................ 5
Outline........................................................................................................................................................ 5
Before the lesson........................................................................................................................................ 5
Lesson details............................................................................................................................................. 6
Section 1: Understanding components of a computer.............................................................................6
Section 2: Understanding functions and conditionals..............................................................................9
Section 3: Wrap-up................................................................................................................................ 13
After the lesson........................................................................................................................................ 14
Lesson A assessments.............................................................................................................................. 14
Lesson B: Code with event handlers............................................................................................................ 15
Lesson plan.............................................................................................................................................. 15
Outline...................................................................................................................................................... 15
Before the lesson...................................................................................................................................... 15
Lesson details........................................................................................................................................... 16
Section 1: Introduce the lesson............................................................................................................. 16
Section 2: Programmable smiles........................................................................................................... 16
Section 3: Wrap-up................................................................................................................................ 25
After the lesson........................................................................................................................................ 25
Lesson B assessments.............................................................................................................................. 26
Lesson C: Fidget cube.................................................................................................................................. 28
Lesson plan.............................................................................................................................................. 28
Outline...................................................................................................................................................... 28
Before the lesson...................................................................................................................................... 28
Tape Lesson details.................................................................................................................................... 3
Section 1: Introduce the lesson............................................................................................................... 3
Section 2: Make a fidget cube................................................................................................................. 3
Section 3: Wrap-up................................................................................................................................ 32
After the lesson........................................................................................................................................ 33
Lesson C assessments.............................................................................................................................. 34

Overview
Unit summary
Introduction to Computer Science Unit 2: Algorithms | 2
This unit introduces students to the four main
components that make up a computer and the concept
of input and output as it relates to programming the
micro:bit. Students will go through two unplugged
activities relating to algorithms and functions that create
a knowledge base for their coding activity and final
project. The coding activity starts with an explanation of Once-a-week timeframe
pseudocode that leads to working with events and event
handlers to program their micro:bit to make faces. The If your class meets only once a week,
project incorporates all the new learning from this unit this unit may take four weeks to
as students create their own fidget cube that responds complete.
to different inputs.
Week 1: Lesson A: How computers
function (only do Crazy Conditionals
Lessons unplugged activity)

Each of the following lessons is intended to be broken Week 2: Lesson B: Code with event
into as many class sessions as needed to complete the handlers
activities.
Weeks 3–4: Lesson C: Fidget cube
Lesson A: How computers function (approx. 45-60 min) (approx. 90-120 min)
Lesson B: Code with event handlers (approx. 60-75 min)
Lesson C: Fidget cube (approx. 60-120 min)

Learning goals
During this unit, students will:

 Understand the four components that make up a computer and their functions.
 Understand that the micro:bit takes input, and after processing the input, produces output.
 Learn the variety of different types of information the micro:bit takes in as input.
 Apply this knowledge by creating a micro:bit program that takes input and produces an output.

CSTA K-12 computer science standards


Targeted standards for this unit:

1B-CS-01 Describe how internal and external parts of computing devices function to form a system.
1B-CS-02 Model how computer hardware and software work together as a system to accomplish tasks.
1B-AP-10 Create programs that include sequences, events, loops, and conditionals.
1B-AP-17 Describe choices made during program development using code comments, presentations, and
demonstrations.
2-AP-10 Use flowcharts and/or pseudocode to address complex problems as algorithms

Introduction to Computer Science Unit 2: Algorithms | 3


Required educator preparation
Preparing to lead the unit
 Watch the correlating unit quick-start video for a brief, high-level introduction to the activities and
project.
 Review all materials thoroughly and become confident with content.
 Practice all activities and check your programming against the solution link provided with the
coding activities.

Required skills
To lead the activities in this unit successfully, you need to be able to:

 Explain the features of the micro:bit.


 Use the following features and blocks in MakeCode:
 Start and name a new project.
 Download a project to the micro:bit.
 Tooltip functions like right-clicking a block for Help, deleting blocks, adding comments, etc.
 ‘on start’, ‘show leds’, and ‘clear screen’ blocks from the Basic Toolbox.
 ‘on button pressed’ block from the Input Toolbox.
 Recommended resources

Recommended resources
If you would like additional support to master the concepts and skills covered in this unit, review the
following resources.

 Learn more about basic micro:bit functions and actions at makecode.microbit.org/reference/basic


 Learn more about micro:bit inputs at makecode.microbit.org/reference/input
 Learn more about on start blocks at makecode.microbit.org/blocks/on-start
 Review micro:bit safety advice at microbit.org/guide/safety-advice
 Search the micro:bit support knowledge base at support.microbit.org/support/home

Introduction to Computer Science Unit 2: Algorithms | 4


Lesson A: How computers function
Lesson plan
1. Introduce the four main components that make up any computer.
2. Lead the two unplugged activities about functions and conditionals.

Outline
Section 1: Understanding components of a computer

 Overview: Introduce the learning goals and introduce components of a computer

Section 2: Understanding functions and conditionals

 Unplugged activity 1: What’s your function


 Unplugged activity 2: Crazy conditionals
 Knowledge check: Check for understanding

Section 3: Wrap-up

 Review: Review learning goals, what the students accomplished, and preview next lesson
 Exit ticket: Distribute and collect the exit ticket to assess learning

Before the lesson


 Review the overview for unplugged activity 1 and:
 Determine the difficulty level of the possible functions so you’re ready to share with the students
ahead of playing. Alternately, you could provide function cards that are handed out at random to
be used by the players rather than the players creating their own.
 Determine if you’ll have students record their work in the provided space in the student
workbooks or provide index cards for the functions.
 Decide how you’ll pair students or whether you’ll let students self-select.
 Review the unplugged activity 2 and:
 Determine if you want to revise the activity and/or conditional statements.
 Determine if one of the extensions/variations is relevant.
 Print out the conditional statements (provided in the table) and cut them into strips with one
conditional per strip.

 Although the student workbooks have space for note-taking, consider having extra paper (or index
cards) available in case any students need more space.
 Print one exit ticket per student (printable versions are found in the assessment guide).

Introduction to Computer Science Unit 2: Algorithms | 5


Lesson details

Section 1: Understanding components of a computer

Educator notes

1. Write the “Do now” on the board for students to think about as they arrive:
What is a computer?
Answer: Responses will vary.
2. Introduce the lesson and learning goals.
3. Discuss their responses to the “Do now.”

Introduction to Computer Science Unit 2: Algorithms | 6


Overview: Components of a
computer
What is a micro:bit? The micro:bit was created in
2015 in the UK by the BBC and partners including
Microsoft to teach computer science to students.
The BBC gave away a micro:bit to every Year 7
(6thgrade) student in the UK. You can think of a
micro:bit as a mini computer.

What is a computer?

There are four main components that make up any computer:

1. The Processor: This is usually a small chip inside the computer,


and it’s how the computer processes and transforms
information. Has anyone heard of the term “CPU”? CPU stands
for Central Processing Unit. You can think of the processor as the
Brains of the computer - the faster the processor, the more
quickly the computer can think.
2. The Memory: This is how the computer remembers things. There
are two types of memory:

 RAM (random access memory): You can think of this as the


computer’s short-term memory. Things that are stored here
will disappear when the computer is turned off. Can you think
of examples of things that are stored in our short-term
memory? Things that you forget after you go to sleep?

 Storage (also referred to as the computer “hard drive”): This is the computer’s long-term memory,
where it can store information even when power is turned off. Can you think of examples of things
that are stored in our long-term memory? Things we never forget?
3. Inputs: This is how a computer takes in information from the world. In humans, our input comes in
through our senses, such as our ears and eyes. What are some computer Inputs? Keyboard, mouse,
touchscreen, camera, microphone, game controller, scanner, etc.
4. Outputs: This is how a computer displays or communicates information. As humans, we communicate
information by using our mouths when we talk. What are some examples of communication that don’t
involve talking? Blushing, sign language. What are some examples of computer outputs?
Monitor/screen, headphones/speakers, printer, etc.

Now, let’s look at our micro:bit (Reference the micro:bit features as needed at
microbit.org/guide/features):

Introduction to Computer Science Unit 2: Algorithms | 7


Note: Though not pictured, the Light Sensor is located on the LED lights.

Ask students:

 Can you find the Processor? Answer: On the back of the micro:bit, just below the Bluetooth and radio
antenna.

 How much memory does the micro:bit have? Answer: 16K, which is smaller than many files on your
computer!

 Can you locate the following Inputs? Answer: Buttons (on board), Pins (at base),
Accelerometer/Compass.

 Where are the Outputs? Answer: LED lights and Pins

All computers need electricity to power them. There are three ways to power your micro:bit:

 Connecting the micro:bit to a computer through the USB port at the top
 Connecting a battery pack to the battery connector
 Through the 3V Pin at the bottom (not the recommended way to power your micro:bit)

On the top left corner, you may notice that your micro:bit has a Bluetooth antenna. This means your
micro:bit can communicate and send information to other micro:bits. We will learn more about this feature
in Unit 10: Radio communication.

Introduction to Computer Science Unit 2: Algorithms | 8


Section 2: Understanding functions and conditionals

Educator notes

1. Follow the instructions to lead the two unplugged activities.


2. After both activities, use the knowledge check questions to confirm understanding.

What is an “unplugged” activity?

An unplugged activity is an activity that takes place away from the computer—in other words,
“unplugged” from technology. This introduces new concepts in a fun way that gets students up and
moving, often reacting and interacting with other students face to face while playing a game or
completing a challenge. Unplugged activities allow students to practice concepts away from devices
so that when they move to coding activities, they have already walked through and thought about
the concepts on their own.

Materials

 Index cards (optional for the first activity)

 Strips of paper, each with one conditional statement on it (prepared in advance for the second
activity)

Knowledge check questions

1. What are the four main components that make up any computer?
Answer: The processor, the memory, the inputs and the outputs
2. How many programmable buttons are on the micro:bit?
Answer: Two

Introduction to Computer Science Unit 2: Algorithms | 9


Unplugged activity 1: What’s your function?

Objective

To guess the mathematical function based on how an input is processed

Overview

For this activity, the students will work in pairs, Player A and Player B. The pairs will take turns being the
function machine for their partner who will be providing input to be processed. The goal is for Player A to
figure out what function (or bit of processing) Player B is using in the fewest number of rounds of
input/output possible.

Here are the roles:

Player B

 Privately determines a mathematical function to apply to a numeric input


 Processes the input from Player A using the function
 Provides the output

Player A

 Provides a number for the input to Player B


 Guesses the function based on the output received from Player B

Examples of easier functions

 Add 8
 Subtract 6
 Multiply by 3
 Divide by 2

Examples of more difficult functions

 Multiply by 2, then subtract 1


 Square the input
 Return 20% of the input

Options for students to record their work

 The student workbooks have a table to record inputs and outputs, or


 Provide index cards so Player A can write each input on one side of an index card, hand the card to
Player B, who then writes the corresponding output on the other side of the card.

Introduction to Computer Science Unit 2: Algorithms | 10


Process

Share the examples of the difficulty level of functions students should use and direct students on how you
would like them to record their work.

1. Player B decides on a mathematical function (or bit of processing) that will be done on whatever input
they receive from Player A. Then they will write it down and set it aside, out of sight of Player A.
2. Player A then gives Player B a number to process.
3. Player B processes the number and returns an output to Player A.
4. Player A can then state what function (or bit of processing) they think Player B is using on the input to
produce the given output. One try per round of input/output.

 If Player A states the correct function, Player B confirms that it is correct by showing the previously
hidden function and the players switch roles and start the game over.

 If Player A does not guess correctly, Player A provides another input that Player B processes and
provides an output for.
5. After each student has had at least one chance to be the function machine, play more rounds as time
permits.

Unplugged activity 2: Crazy conditionals

Objective

This is a fun, interactive exercise to introduce conditionals and event handlers as computer processing.

Read through the entire activity and adjust as needed for your students and classroom.

Process
1. Hand out the conditional strips to the number of students as noted in the table below, and following
these guidelines:

 Some of the same conditionals can be given to multiple students, while other conditionals are to be
given to just one student.

 Besides the ‘BEGIN’ and ‘STOP’ conditional, give at least two other conditionals to each student. A
lesson from this is that it is challenging for a student to keep track of a lot of different conditionals,
though not so for a computer!

 Except for the first ‘BEGIN’ conditional, hand out the conditionals print side down.
Note: Technically, these conditionals are all event handlers because the students are simply waiting for
a specific event to trigger them into action.
2. Unless instructed otherwise, students do not speak or make noise during this activity.
3. Start the activity by writing BEGIN on the whiteboard.
4. As the activity progresses, trigger the six conditionals multiple times, e.g., say “popcorn,” write on the
whiteboard with a green marker and/or snap your fingers multiple times, etc.
5. When you want to wrap up the activity, trigger the final seven conditionals by picking up a book, then
the remaining triggers, e.g., open/close the classroom door, turn the lights on/off, sharpen a pencil.

Introduction to Computer Science Unit 2: Algorithms | 11


Two conditionals for all students:
 These two conditionals will be triggered only once.
 These conditionals start and stop this activity.
 Give the first BEGIN conditional to the students print side up.

IF you see the word BEGIN on the whiteboard,


THEN flip over the conditionals in front of you and follow the directions.
IF you see the word STOP on the whiteboard,
THEN sit back, cross your arms, and look at your instructor and smile!

Six conditionals for multiple students:


 These six conditionals may be triggered more than once.
 Walk around the classroom during the activity to trigger some of these conditionals.

IF the instructor says the word “popcorn,”


THEN stand up and say “Pop!” once and sit back down.
IF any student stands up for any reason,
THEN clap three times.
IF anyone writes on the whiteboard with a GREEN marker,
THEN get up and touch something GREEN in the room and sit back down.
IF anyone walks past you while you are seated,
THEN snap your fingers three times.
IF someone snaps their fingers AND you have the letter “e” in your first name,
THEN select a book from the bookcase and sit back down.
IF anyone writes anything on the whiteboard,
THEN get up and turn around in place one full turn and sit back down.

Introduction to Computer Science Unit 2: Algorithms | 12


Seven conditionals for one student:
These will be triggered only once and set in motion the spelling of STOP on the whiteboard.

IF the educator picks up a book,


THEN get up and write the letter S on the whiteboard and sit back down.
IF someone writes the letter S on the whiteboard,
THEN go open and close the classroom door and sit back down.
IF someone opens and closes the classroom door,
THEN get up and write the letter T (after the letter S) on the whiteboard.
IF someone writes the letter T on the whiteboard,
THEN get up and turn the lights on and off and sit back down.
IF someone turns the light on and off,
THEN get up and write the letter O (after the letter T) on the whiteboard.
IF someone writes the letter O on the whiteboard,
THEN get up and sharpen a pencil.
IF someone sharpens a pencil,
THEN get up and write the letter P (after the letter O) on the whiteboard.

Extensions/variations
 Add AND, OR, AND/OR statements to the conditionals.
 Create nested IFs.
 Let students create the IFs.
 Relate this activity to a system and have students create the conditionals that would end in a
product of some kind or the completion of some task.

Knowledge check: Assess understanding


Discuss the knowledge check questions and answers with students.

Section 3: Wrap-up

Educator notes

1. Review learning goals with students, what they accomplished, and preview the next lesson.
2. Distribute and collect the exit ticket.

After the lesson

Introduction to Computer Science Unit 2: Algorithms | 13


Assessment
 Review the exit ticket responses.

Reflection
 Consider if there were any concepts of the lesson or exit ticket students struggled with that you
might want to reinforce or re-teach at the beginning of the next lesson.
 Consider what aspects of the lesson students found engaging and how you might emphasize those
in the next lesson.
 Follow up on any questions that arose during the lesson that require additional research on your
part.

Lesson A assessments

“Do now”

Format: Written on the board at the start of the lesson.

 What is a computer?
Answer: Responses will vary

Knowledge check questions and answers

Format: Q&A discussions during the lesson.

Questions (slide 8) Answers

What are the four main components The processor, the memory, the inputs and the outputs
that make up any computer?

How many programmable buttons are Two


on the micro:bit?

Exit ticket

Format: Printed half-page handout for students to complete and turn in as they leave class. (Printer-
friendly versions are found in the assessment guide.)

Questions Answers

Name a real-life event from today’s Responses will vary


class that caused an action.

Introduction to Computer Science Unit 2: Algorithms | 14


Lesson B: Code with event handlers
Lesson plan
1. Lead the “Happy face, sad face” coding activity.
2. Assess learning with the unit quiz.

Outline
Section 1: Introduce the lesson

 Overview: Introduce the learning goals

Section 2: Programable smiles

 Coding activity: Happy face, sad face


 Knowledge check: Unit quiz

Section 3: Wrap-up

 Review: Review learning goals, what the students accomplished, and preview next lesson

Before the lesson


 Ensure you have the needed hardware for each student (or pair):
 Computer, laptop, or tablet
 Micro:bit
 Micro-USB cable
 Battery pack (with two AAA batteries)
 Print one quiz per student (see the assessment guide for a printable format).

Introduction to Computer Science Unit 2: Algorithms | 15


Lesson details

Section 1: Introduce the lesson

Educator notes

1. Write the “Do now” question on the board for students to think about as they arrive:
Write down two examples of computer input and two examples of computer output
Answer: Responses will vary
2. Introduce the lesson and learning goals.
3. Discuss their responses to the “Do now.”

Section 2: Programmable smiles

Educator notes

1. Use your established equipment safety procedures for distributing and using the hardware and
ensure students are properly set up to begin coding in MakeCode and micro:bit.
2. Follow the instructions to lead the birdhouse activity. Do the activity on your device connected to
the projector or presentation screen and have students follow along as you complete each step. If
you don’t have a projector or screen, move throughout the room between steps to check for
understanding and help facilitate the activity.
3. Pause after each step to check for understanding and take questions as needed.
4. After the activity, distribute the quiz (see the assessment guide for a printable format).
5. If you have time during class, consider reviewing the quiz answers as a group activity.

What is a “birdhouse” activity?

Each unit contains a micro:bit activity, which we informally refer to as a “birdhouse” activity, after
the innumerable wooden birdhouses so many of us made in wood shop as a way to master basic
skills. The activity is an example that walks students step by step through building a project that
demonstrates that unit’s topic. By the time students finish the activity, they will have written code
that they can use in a different project of their own design.

Introduction to Computer Science Unit 2: Algorithms | 16


Tips
Some students will finish the activity more quickly than others. Those students can then be a helpful
resource for their classmates or they can challenge themselves by modifying, or “modding”, the
activity to do something different. We have provided examples and suggestions at the end of many
of these activities. Feel free to suggest your own (or encourage your students to come up with their
own ideas!)

Coding activity: Happy face, sad face


The micro:bit itself is considered hardware. It is a physical piece of technology. In order to make use of
hardware, we need to write software (otherwise known as “code” or computer programs). The software
“tells” the hardware what to do—and in what order to do it using algorithms. Algorithms are sets of
computer instructions.

In this activity, we will discover how to use the micro:bit buttons as input devices and write code that will
make something happen on the screen as output. We will also learn about pseudocode, the MakeCode
tool, event handlers, and commenting code.

Pseudocode

What do you want your program to do? The first step in writing a computer program is to create a plan for
what you want your program to do. Write out a detailed step-by-step plan for your program. Your plan
should include what type of information your program will receive, how this input will be processed, what
output your program will create, and how the output will be recorded or presented. Your writing does not
need to be written in complete sentences nor include actual code. This kind of detailed writing is known as
pseudocode. Pseudocode is like a detailed outline or rough draft of your program. Pseudocode is a mix of
natural language and code.

For the program we will write, the pseudocode might look like this:

 Start with a blank screen.


 Whenever the user presses button A, display a happy face.
 Whenever the user presses button B, display a sad face.

Introduction to Computer Science Unit 2: Algorithms | 17


Microsoft MakeCode

Now that you have a plan for your program in the form of pseudocode, let’s start creating the real program
in Microsoft MakeCode. Remember, the MakeCode tool is called an IDE (Integrated Development
Environment) and is a software application that contains everything a programmer needs to create,
compile, run, test, and even debug a program.

1. In Microsoft MakeCode, start a new project.

Event handlers

When you start a new project, there will be two blue blocks, ‘on start’ and ‘forever’, already in the coding
Workspace. These two blocks are event handlers.

In programming, an event is an action done by the user, such as pressing a key or clicking a mouse button.
An event handler is a routine that responds to an event. A programmer can write code telling the computer
what to do when an event occurs.

Tool tips

Experiment with the following options.

2. Block descriptions: Hover over any block until a hand icon appears and a small text box will pop up
telling you what that block does. You can try this now with the ‘on start’ and ‘forever’ blocks.

Hovering over the code in JavaScript has the same effect.

Help: You can also right-click on any block and select Help to open the reference documentation.

Introduction to Computer Science Unit 2: Algorithms | 18


3. Deleting blocks: Select the ‘forever’ block and drag it left to the Toolbox area. You should see a
garbage can icon appear. Let go of the block and it should disappear. You can drag any block back to
the Toolbox area to delete it from the coding Workspace. You can also remove a block from the coding
Workspace by:
 Hovering over the block, right-clicking, and selecting Delete Block, or
 Selecting the block and then pressing the “delete” key on your keyboard (or command-X on a mac).

Clear screen
4. Looking at our pseudocode, we want to be sure to start a program with a clear screen. We can do this
by going to the Basic menu, selecting … more, and then a ‘clear screen’ block.

Introduction to Computer Science Unit 2: Algorithms | 19


5. Drag the ‘clear screen’ block to the coding Workspace. Notice that the block is grayed out. If you hover
over the grayed-out block, a pop-up text box will appear letting you know that since this block is not
attached to an event handler block, it will not run.

6. Go ahead and drag the ‘clear screen’ block into the ‘on start’ block. Now the block is no longer grayed
out, indicating that it will run when the event occurs—i.e., the program starts.

Save early, save often!

We now have a working program running on the micro:bit simulator! As you write your program,
MakeCode will automatically compile and run your code on the simulator. The program doesn’t do much at
this point, but before we make it more interesting, we should name our program and save it.

7. On the bottom left of the application window, to the right of the Download button, is a text box in which
you can name your program. After naming your program, select the save button to save it.

Important: Whenever you write a significant piece of code or just every few minutes, you should save your
code. Giving your code a meaningful name will help you find it faster and let others know what your
program does.

Introduction to Computer Science Unit 2: Algorithms | 20


More event handlers

Now to make our program a bit more interesting by adding two more event handlers.

8. From the Input menu, drag two ‘on button A pressed’ blocks to the coding Workspace. Notice that the
second block is grayed out. This is because, right now, they are the same block, both “listening” for the
same event ‘on button A pressed’.

9. Leave the first block alone for now, and using the drop-down menu within the second block, change the
A to B. Now this block will no longer be grayed out, as it is now listening for a different event, ‘on
button B pressed’.

Introduction to Computer Science Unit 2: Algorithms | 21


Show LEDs

Now we can use our LED lights to display different images depending on what button the user presses.

10. From the Basic Toolbox, drag two ‘show leds’ blocks to the coding Workspace. Place one ‘show leds’
block into the ‘on button A pressed’ event handler and the second ‘show leds’ block into the ‘on button
B pressed’ event handler.

11. Select the individual little boxes in the ‘show leds’ block that is in the ‘on button A pressed’ event
handler to create the image of a happy face. Select the individual little boxes in the ‘show leds’ block
that is in the ‘on button B pressed’ event handler to create the image of a sad face.

Introduction to Computer Science Unit 2: Algorithms | 22


Test your program!
12. In the Simulator, press button A and then button B to see the output produced by your code.

Feel free to play around with turning LEDs on or off in the ‘show leds’ blocks until you get the images you
want.

Remember to save your code.

Commenting on your code

It is good practice to add comments to your code. Comments can be useful in a number of ways.
Comments can help you remember what a certain block of code does and/or why you chose to program
something the way you did. Comments also help others reading your code to understand these same
things.

To comment on a block of code:

 Right-click on the icon that appears before the words on a block.


 A menu will pop up. Select ‘Add Comment’.

Introduction to Computer Science Unit 2: Algorithms | 23


 This will cause a question mark icon to appear to the left of the previous icon.
 Select the question mark and a small yellow box will appear into which you can write your comment.

 Select the question mark icon again to close the comment box when you are done.
 Select the question mark icon whenever you want to see your comment again or to edit it.

In JavaScript, you can add a comment by using two forward slashes, then typing your comment. The two
forward slashes tell JavaScript that the following text (on that same line) is a comment.

// Display a happy face when button A is pressed.

Cleaning up!
13. Clean up your coding Workspace before you do a final save. What does this mean?

 It means that only the code and blocks that you are using in your program are still in the workspace.
 Remove (delete) any other blocks that you may have dragged into the coding workspace as you
were experimenting and building your program.

Save and download


14. Now that your code is running just fine in the Simulator, is commented, and your coding Workspace is
“clean,” save your program, download it to your micro:bit, play and enjoy!

Introduction to Computer Science Unit 2: Algorithms | 24


Complete program

Solution link: makecode.microbit.org/_WPicbA7gR7xc

Activity: Unit Quiz


Distribute the quiz (printable versions are found in the assessment guide). If you have time during class,
consider reviewing the quiz answers as a group activity.

Section 3: Wrap-up

Educator notes

1. Review learning goals with students, what they accomplished, and preview the next lesson.
2. Use your established equipment safety procedures for collecting and storing the hardware.

After the lesson

Assessment
 Review and grade the quiz (unless you reviewed with students in class).

Reflection
 Consider if there were any concepts of the lesson or quiz students struggled with that you might
want to reinforce or re-teach at the beginning of the next lesson.
 Consider what aspects of the lesson students found engaging and how you might emphasize those
in the next lesson.
 Follow up on any questions that arose during the lesson that require additional research on your
part.

Introduction to Computer Science Unit 2: Algorithms | 25


Lesson B assessments

“Do now”

Format: Written on the board at the start of the lesson.

 Write down two examples of computer input and two examples of computer output.
Answer: Responses will vary

Quiz

Format: Printed full-page handout for students to complete during class. (Please see the assessment guide
for printer-friendly versions to distribute to students.)

Questions Answers

1. What is a computer processor? d. A small chip inside the computer that


the computer uses to process and
a. Where the computer stores its memory
transform information
b. The face of the micro:bit
c. The area of a MakeCode project that shows how a
program looks when run on the micro:bit
d. A small chip inside the computer that the
computer uses to process and transform
information

2. What is the difference between RAM and hard drive a. RAM is the computer’s short-term
memory? memory and the hard drive is where the
computer stores its long-term memory.
a. RAM is the computer’s short-term memory and
the hard drive is where the computer stores its
long-term memory.
b. The hard drive is where the computer stores its
short-term memory and RAM is the computer’s
long-term memory.
c. RAM is used for programming and the hard drive
memory is for storage.
d. Hard drive memory is for storing files and RAM is
used for processing inputs.

3. The term input describes: c. How a computer takes in information


from the world
a. A type of RAM memory
b. A computer speaker
c. How a computer takes in information from the
world
d. How a computer processes information

4. The term output describes: a. How a computer displays or


communicates information
a. How a computer displays or communicates
information
b. The way a computer stores memory

Introduction to Computer Science Unit 2: Algorithms | 26


c. Where cords, like a USB cable, connect to a
computer
d. A type of RAM memory

5. What’s an algorithm? b. Sets of instructions to a computer


a. The word used to describe all computer codes
b. Sets of instructions to a computer
c. A type of hardware used with micro:bit
d. The area of a MakeCode project that shows how a
program looks when run on the micro:bit

6. What’s a function machine? a. One that takes an input, processes


the input, and then delivers an output
a. One that takes an input, processes the input, and
then delivers an output
b. One that can understand many different coding
languages
c. A computer designed for a single task
d. A peripheral machine that connects to a computer

7. Is a micro:bit an example of hardware or software? Hardware.

8. What is pseudocode? b. A detailed step-by-step plan for your


program
a. The coding blocks in MakeCode
b. A detailed step-by-step plan for your program
c. A coding language
d. A computer program

9. What is an event in programming? An action done by the user, such as


pressing a key or clicking a mouse
button

10. What is an event handler? A routine that responds to an event

Introduction to Computer Science Unit 2: Algorithms | 27


Lesson C: Fidget cube
Lesson plan
1. Introduce and facilitate the coding project.

Outline
Section 1: Introduce the lesson

 Overview: Introduce the learning goals

Section 2: Make a fidget cube

 Coding project: Fidget cube

Section 3: Wrap-up

 Exit ticket: Students complete a Reflection Diary entry for their project
 Review: Review the learning goals, what students accomplished, and preview next unit

Before the lesson


 If you will be reviewing the lesson B quiz, prepare to address any themes the students are
struggling with.

 Email the Reflection Diary questions for the project to students or post it in a shared drive so
students can send their responses to you electronically.

 Ensure you have the needed hardware for each student (or pair):
 Computer, laptop, or tablet
 micro:bit
 Micro-USB cable
 Battery pack (with two AAA batteries)
 Although the student workbooks have space for note taking and drawing, consider having extra
paper available in case any students need more design space.

 Ensure the arts and crafts supplies are restocked, e.g.:


 Pizza boxes/scrap cardboard  Stickers/adhesives
 Colored construction paper  Feathers, beads, etc.
 Foil and copper tape  String
 Scissors  Colored markers/pencils
 Pipe cleaners  Glue

Introduction to Computer Science Unit 2: Algorithms | 28


Tape Lesson details

Section 1: Introduce the lesson

Educator notes

1. Write the “Do now” on the board for students to think about as they arrive:
Do you ever fidget? If so, what kinds of things do you fidget with regularly?
Answer: Responses will vary
2. Introduce the learning goals and discuss responses to the “Do Now.”
3. Review any themes that students are struggling with from the quiz results unless you covered
this at the end of the last lesson.

Section 2: Make a fidget cube

Educator notes

1. Use your established equipment safety procedures for distributing and using the hardware and
ensure students are properly set up to begin coding in MakeCode and micro:bit.
2. Follow the instructions to explain the expectations for their project, provide ideas, examples, and
the scoring rubric, which are also in the student workbook.
3. Encourage students who finish early or need an extra challenge to try one or more of the mod
ideas.
4. After the activity, consider having students share their projects in pairs, small groups, or with the
rest of the class as time allows.
5. Be sure to allow enough time for students to complete their Reflection Diary entry in the next
section.

Objective of projects

Open-ended projects are opportunities to apply the concepts and skills students have developed in
an original and creative way. Students will work on their projects in a “collaboratively independent”
way, which means each student is responsible for turning in his or her own project but are
encouraged to work together and help each other while doing so. Some form of reflection is an
important part of documenting the learning that has taken place.

Activity: Fidget cube


A fidget cube is a little cube with something different that you can manipulate
on each surface. There are buttons, switches, and dials, and people who like

Introduction to Computer Science Unit 2: Algorithms | 29


to “fidget” find it relaxing to push, pull, press, and play with it. In this project, students are challenged to
turn the micro:bit into their very own “fidget cube”.

Show students the funny fidget cube video (5:09) in the presentation deck.

This project is to make a fidget cube out of the micro:bit and create a unique output for each of the
following inputs:

 on button A pressed
 on button B pressed
 on button A+B pressed
 on shake

See if you can combine a maker element similar to what you created in Unit 1 by providing a holder for the
micro:bit that holds it securely when you press one of the buttons.

Discussion questions

Use the following questions to help get students started:

 Do any of your students fidget?


 What kinds of things do they fidget with? Spinning pens, fidget spinners, rings, coins?
 There are many different versions of fidget cubes available now. Do any students have any?
 Have they seen them before?
 What are the types of fidget activities?
 If students could add or modify features of the fidget cube, what would they choose to do?
 What would make the ultimate fidget cube?

Remind students that a computing device has a number of inputs and outputs. The code that we write
processes input by telling the micro:bit what to do when various events occur.

Fidget cube example

If you have less time…

…or if your learners are beginners, this


project is available as a commented
MakeCode template:
https://makecode.microbit.org/_WbdD51Mr
XMD8. The template will open to the
default setting to show block programming.
For more of a challenge, learners can
choose to view and use the template code
in JavaScript or Python.

Introduction to Computer Science Unit 2: Algorithms | 30


Project mods
 Add more inputs and more outputs; use more than four different types of input.
 Try to use other types of output (other than LEDs) such as sound!

Project expectations

Follow the design thinking approach and make sure your project meets the required specifications:

 Uses at least four different inputs


 Uses at least four different outputs
 Uses event handlers in a way that is integral to the program
 The program compiles and runs as intended and uses meaningful comments
 Includes the written Reflection Diary entry (which we’ll talk about after you complete your project)

Introduction to Computer Science Unit 2: Algorithms | 31


Project scoring rubric

Assessment
1 2 3 4
elements

Inputs Fewer than two At least two At least three At least four different
different inputs different inputs different inputs inputs are
are successfully are successfully are successfully successfully
implemented. implemented. implemented. implemented.

Outputs Fewer than two At least two At least three At least four different
different outputs different outputs different outputs outputs are
are successfully are successfully are successfully successfully
implemented. implemented. implemented. implemented.

micro:bit program micro:bit program micro:bit program micro:bit program


micro:bit program:
lacks all of the lacks two of the lacks one of the
required required required
elements. elements. elements.  Uses event
handlers in a way
that is integral to
the program

 Compiles and runs


as intended

 Uses meaningful
comments in code

Section 3: Wrap-up

Educator notes

1. Explain the expectations and scoring rubric for the Reflection Diary entry for their project (also in
the student workbook).
2. Review the learning goals, what students accomplished, and preview the next unit.
3. Use your established equipment safety procedures for collecting and storing the hardware.

Introduction to Computer Science Unit 2: Algorithms | 32


Reflection Diary

Expectations

Write a reflection of about 150–300 words, addressing the following points:

 What problem did you solve, or why did you decide to create this project?
 What kind of input and output did you decide to use?
 What does your program do? Describe how your program works (what the cause and effect are).
 Include at least one screenshot of your program working.
 Publish your MakeCode program and include the URL.

Diary entry scoring rubric

Assessment
1 2 3 4
elements

Diary entry Diary entry is Diary entry is Diary entry is Diary entry
missing three or missing two of the missing one of the addresses all
more of the required elements. required elements. elements.
required elements.

After the lesson

Assessment
 Review and grade the projects and diary entries. (A full page, printer-friendly version of the project
scoring rubric is available in the assessment guide.)

Reflection
 Consider if there were any concepts of the lesson, project, or diary entries students struggled with
that you might want to reinforce or re-teach before or at the beginning of the next unit.
 Consider what aspects of the lesson students found engaging and how you might emphasize those
in the next unit.
 Follow up on any questions that arose during the lesson that require additional research on your
part.

Introduction to Computer Science Unit 2: Algorithms | 33


Lesson C assessments

“Do now”

Format: Written on the board at the start of the lesson:

 Do you ever fidget? If so, what kinds of things do you fidget with regularly?
Answer: Responses will vary

Reflection Diary questions

Format: Provide to students electronically. Copy and paste from below.

Unit 2 Algorithms: Reflection Diary

Compose a diary entry addressing the following:

 What problem did you solve, or why did you decide to create this project?
 What kind of input and output did you decide to use?
 What does your program do? Describe how your program works (what the cause and effect are).
 Include at least one screenshot of your program working.
 Publish your MakeCode program and include the URL.

Introduction to Computer Science Unit 2: Algorithms | 34

You might also like