Teaching the Principles of Computer Science to Primary-Aged Children

Post on 10-Dec-2014

1.088 views 3 download

Tags:

description

UCC Science, Engineering & Food Science Public Lecture - Professor Barry O'Sullivan Computers are extremely important in modern life. Understanding how they work, how they reason, how they "think", what are their limitations, is a fascinating subject called computer science.This lecture is focused on making the fundamental ideas of computer science accessible to children from the ages of 7-12 and their families. We present a set of learning activities that teach computer science through engaging games and puzzles that use cards, string, crayons and lots of running around. This lecture presents a subset of activities that form part of a Public Engagement Programme for Dublin City of Science 2012. Professor Barry O'Sullivan is Head of Department for Computer Science at University College Cork, Ireland. He is also Director of the Cork Constraint Computation Centre in the Computer Science Department at UCC, SFI Principal Investigator, Past President of the Association for Constraint Programming, Chairman of the Artificial Intelligence Association of Ireland, Coordinator of the EuropeanResearch Consortium for Informatics and Mathematics Working Group on Constraints, and Executive Council member of the Analytics Society of Ireland.

Transcript of Teaching the Principles of Computer Science to Primary-Aged Children

Teaching the Principles of Computing to Primary-Aged Kids

Professor Barry O’Sullivanand Kate O’Sullivan (Age 9)

My Assistant

Kate will help me with demonstrations.

Preview of a Public Engagement Event at the ESOF 2012, Dublinhttp://esof2012.org/

Credits: Computer Science Unplugged Resources

Computer science is about how we can solve problems with computersMulti-disciplinary, rich, deep, and rewarding area of study

What will we be talking about tonight?

• Computer science is important - economically and intellectually

• From Binary Numbers to Images and Codes

• What’s wrong with my brain? (Human Computer Interaction, Stroop Effect)

• Running Together (Sorting, Data Structures, and Parallel Computing)

• Coloring In (Graph Coloring, Combinatorics and Complexity Theory)

• Card Trick (Error Detection and Correction)

• Scratch (Computer Programming for Children)

Computer science is importantEconomically and intellectually

Consistently considered the best job in the USAhttp://money.cnn.com

Best Jobs in the World, 2011http://www.careercast.com

Skills Required by New IDA Investments in 2011

Other8%Sales

12%

Manuf.14%

Business19%

ICT47%

ICT Business Manuf. Sales Other

13,000 jobs in 2011148 investments No recession in software!

Let’s get started with some magic!

Photocopiable for classroom use only. 5

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0,12#.)3456'#%)

7'2#1,18)&"9)(")+"41()So, you thought you knew how to count? Well, here is a new way to do it!

Did you know that computers use only zero and one? Everything that you see or hear on the computer—words, pictures, numbers, movies and even sound is stored using just those two numbers! These activities will teach you how to send secret messages to your friends using exactly the same method as a computer.

:1%(#4+(,"1%)Cut out the cards on your sheet and lay them out with the 16-dot card on the left as shown here:

Make sure the cards are placed in exactly the same order.

Now flip the cards so exactly 5 dots show—keep your cards in the same order!

Find out how to get 3, 12, 19. Is there more than one way to get any number? What is the biggest number you can make? What is the smallest? Is there any number you can’t make between the smallest and biggest numbers?

Extra for Experts: Try making the numbers 1, 2, 3, 4 in order. Can you work out a

logical and reliable method of flipping the cards to increase any number by one? Representing DataBinary Numbers

• Computers use the binary system to represent numbers.

• What is binary? A two-valued number system - only numbers being 0 and 1

• In school you might have known it as ‘base 2’. We use ‘base 10’ everyday.

• Each 0 or 1 is a bit, and computers use transistors to represent them.

• How do we get large numbers? Using many bits.

• Eight bits is a byte.

Binary Numbers - What’s this about?

Understanding Binary

4 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Binary Numbers

Introduction

Before giving out the worksheet on page 5, it can be helpful to demonstrate the principles

to the whole group.

For this activity, you will need a set of five cards, as shown below, with dots on one side

and nothing on the other. Choose five children to hold the demonstration cards at the

front of the class. The cards should be in the following order:

Discussion

What do you notice about the number of dots on the cards? (Each card has twice as many

as the card to its right.)

How many dots would the next card have if we carried on to the left? (32) The next…?

We can use these cards to make numbers by turning some of them face down and adding

up the dots that are showing. Ask the children to make 6 (4-dot and 2-dot cards), then 15

(8-, 4-, 2- and 1-dot cards), then 21 (16, 4 and 1)…

Now try counting from zero onwards.

The rest of the class needs to look closely at how the cards change to see if they can see a

pattern in how the cards flip (each card flips half as often as the one to its right). You may

like to try this with more than one group.

When a binary number card is not showing, it is represented by a zero. When it is

showing, it is represented by a one. This is the binary number system.

Ask the children to make 01001. What number is this in decimal? (9) What would 17 be

in binary? (10001)

Try a few more until they understand the concept.

There are five optional follow-up extension activities, to be used for reinforcement. The

children should do as many of them as they can.

Numbers in Binary

4 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Binary Numbers

Introduction

Before giving out the worksheet on page 5, it can be helpful to demonstrate the principles

to the whole group.

For this activity, you will need a set of five cards, as shown below, with dots on one side

and nothing on the other. Choose five children to hold the demonstration cards at the

front of the class. The cards should be in the following order:

Discussion

What do you notice about the number of dots on the cards? (Each card has twice as many

as the card to its right.)

How many dots would the next card have if we carried on to the left? (32) The next…?

We can use these cards to make numbers by turning some of them face down and adding

up the dots that are showing. Ask the children to make 6 (4-dot and 2-dot cards), then 15

(8-, 4-, 2- and 1-dot cards), then 21 (16, 4 and 1)…

Now try counting from zero onwards.

The rest of the class needs to look closely at how the cards change to see if they can see a

pattern in how the cards flip (each card flips half as often as the one to its right). You may

like to try this with more than one group.

When a binary number card is not showing, it is represented by a zero. When it is

showing, it is represented by a one. This is the binary number system.

Ask the children to make 01001. What number is this in decimal? (9) What would 17 be

in binary? (10001)

Try a few more until they understand the concept.

There are five optional follow-up extension activities, to be used for reinforcement. The

children should do as many of them as they can.

Some Fun with Binary

• How to we make:

• 3

• 12

• 19

• What do these numbers mean?

• 10101

• 01010

Binary can encode words and messages!

8 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0'12,13)0'+#'()4'%%53'%)

Tom is trapped on the top floor of a department store. It’s just before Christmas and he wants to get home with his presents. What can he do? He has tried calling, even yelling, but there is no one around. Across the street he can see some computer person still working away late into the night. How could he attract her attention? Tom looks around to see what he could use. Then he has a brilliant idea—he can use the Christmas tree lights to send her a message! He finds all the lights and plugs them in so he can turn them on and off. He uses a simple binary code, which he knows the woman across the street is sure to understand. Can you work it out?

6) 7) 8) 9) :) ;) <) =) >) 6?) 66) 67) 68)

5) @) +) 2) ') A) 3) &) ,) B) $) C) D)69) 6:) 6;) 6<) 6=) 6>) 7?) 76) 77) 78) 79) 7:) 7;)

1) ") E) F) #) %) () G) -) H) I) .) J)

Kate will help us decode a message encoded in binary

Binary enables communications

Photocopiable for classroom use only. 9

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0123,4)356)7"6'2%)

Computers connected to the internet through a modem also use the binary system to send messages. The only difference is that they use beeps. A high-pitched beep is used for a one and a low-pitched beep is used for a zero. These tones go very fast—so fast, in fact, that all we can hear is a horrible continuous screeching sound. If you have never heard it, listen to a modem connecting to the Internet, or try calling a fax machine—fax machines also use modems to send information.

Using the same code that Tom used in the department store, try sending an e-mail message to your friend. Make it easy for yourself and your friend though—you don’t have to be as fast as a real modem!

Photocopiable for classroom use only. 15

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Colour by Numbers

Introduction

Discussion Questions

1. What do facsimile (fax) machines do?

2. In what situations would computers need to store pictures? (A drawing program, a

game with graphics, or a multi-media system.)

3. How can computers store pictures when they can only use numbers?

(You may like to arrange for the children to send and/or receive faxes as a preparation for

this activity)

Demonstration using OHP transparency

Computer screens are divided up into a grid of small dots called pixels (picture elements).

In a black and white picture, each pixel is either black or white.

The letter “a” has been magnified above to show the pixels. When a computer stores a

picture, all that it needs to store is which dots are black and which are white.

!"#$"#!#

%"#!#

!"#%#

&"#!"#$"#!#

&"#!"#$"#!#

!"#%#

The picture above shows us how a picture can be represented by numbers. The first line

consists of one white pixel, then three black, then one white. Thus the first line is

represented as 1, 3, 1.

The first number always relates to the number of white pixels. If the first pixel is black

the line will begin with a zero.

The worksheet on page 17 gives some pictures that the children can decode using the

method just demonstrated.

Representing Images on a ComputerData Compression - Run-Length Encoding

• Each computer screen is a grid of dots, called pixels

• The simplest screens have only black and white pixels

• By turning on/off the dots we can make pictures, text, etc.

• Grayscale screens have pixels that have a shade between black and white

• Color screens have pixels that have millions of different colors

• Images can be represented as numbers, and there are lots of different ways of doing that

How are images represented?

A simple image of the letter ‘a’

Photocopiable for classroom use only. 15

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Colour by Numbers

Introduction

Discussion Questions

1. What do facsimile (fax) machines do?

2. In what situations would computers need to store pictures? (A drawing program, a

game with graphics, or a multi-media system.)

3. How can computers store pictures when they can only use numbers?

(You may like to arrange for the children to send and/or receive faxes as a preparation for

this activity)

Demonstration using OHP transparency

Computer screens are divided up into a grid of small dots called pixels (picture elements).

In a black and white picture, each pixel is either black or white.

The letter “a” has been magnified above to show the pixels. When a computer stores a

picture, all that it needs to store is which dots are black and which are white.

!"#$"#!#

%"#!#

!"#%#

&"#!"#$"#!#

&"#!"#$"#!#

!"#%#

The picture above shows us how a picture can be represented by numbers. The first line

consists of one white pixel, then three black, then one white. Thus the first line is

represented as 1, 3, 1.

The first number always relates to the number of white pixels. If the first pixel is black

the line will begin with a zero.

The worksheet on page 17 gives some pictures that the children can decode using the

method just demonstrated.

A simple image of the letter ‘a’

Photocopiable for classroom use only. 15

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Colour by Numbers

Introduction

Discussion Questions

1. What do facsimile (fax) machines do?

2. In what situations would computers need to store pictures? (A drawing program, a

game with graphics, or a multi-media system.)

3. How can computers store pictures when they can only use numbers?

(You may like to arrange for the children to send and/or receive faxes as a preparation for

this activity)

Demonstration using OHP transparency

Computer screens are divided up into a grid of small dots called pixels (picture elements).

In a black and white picture, each pixel is either black or white.

The letter “a” has been magnified above to show the pixels. When a computer stores a

picture, all that it needs to store is which dots are black and which are white.

!"#$"#!#

%"#!#

!"#%#

&"#!"#$"#!#

&"#!"#$"#!#

!"#%#

The picture above shows us how a picture can be represented by numbers. The first line

consists of one white pixel, then three black, then one white. Thus the first line is

represented as 1, 3, 1.

The first number always relates to the number of white pixels. If the first pixel is black

the line will begin with a zero.

The worksheet on page 17 gives some pictures that the children can decode using the

method just demonstrated.

This is a data compression technique called Run-Length Encoding!

Photocopiable for classroom use only. 17

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0,1)234)

The first picture is the easiest and the last one is the most complex. It is easy to make mistakes and therefore a good idea to use a pencil to colour with and have a rubber handy!

!"#$$#

!"#%"#&"#$#

!"#%"#&"#$#

!"#$$#

!"#%#

!"#%#

'"#(#

)"#$(#

$"#$'#

*"#'"#&"#+#

!"#&"#'"#&"#+"#$#

+"#$"#%"#$"#&"#$#

+"#$"#%"#$"#$"#$#

&"#$"#$$"#$#

&"#$"#$)"#&#

&"#$"#%"#$"#$"#$#

&"#$"#,"#$"#&"#$#

&"#$"#("#$"#+"#$#

$"#$"#$"#$"#!"#&"#+"#$#

)"#$"#&"#$"#&"#&"#'"#$#

)"#$"#+"#&"#'"#&#

$"#+"#&"#'#

*"#&"#&"#&#

'"#$"#&"#&"#&"#$#

*"#*#

!"#&"#*"#&#

+"#$"#$)"#$#

&"#$"#$&"#$#

&"#$"#+"#$"#!"#$"#+"#$#

$"#&"#$&"#&#

)"#$"#$*"#$#

)"#$"#*"#$"#&"#$"#*"#$#

)"#$"#("#&"#("#$#

$"#$"#$!"#$#

&"#$"#$&"#$#

&"#$"#'"#&"#'"#$#

+"#$"#$)"#$#

!"#&"#*"#&#

*"#*#

Kate will help us with some images....

Photocopiable for classroom use only. 17

© 2002 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

!"#$%&''()*+(,-,(./)0,1)234)

The first picture is the easiest and the last one is the most complex. It is easy to make mistakes and therefore a good idea to use a pencil to colour with and have a rubber handy!

!"#$$#

!"#%"#&"#$#

!"#%"#&"#$#

!"#$$#

!"#%#

!"#%#

'"#(#

)"#$(#

$"#$'#

*"#'"#&"#+#

!"#&"#'"#&"#+"#$#

+"#$"#%"#$"#&"#$#

+"#$"#%"#$"#$"#$#

&"#$"#$$"#$#

&"#$"#$)"#&#

&"#$"#%"#$"#$"#$#

&"#$"#,"#$"#&"#$#

&"#$"#("#$"#+"#$#

$"#$"#$"#$"#!"#&"#+"#$#

)"#$"#&"#$"#&"#&"#'"#$#

)"#$"#+"#&"#'"#&#

$"#+"#&"#'#

*"#&"#&"#&#

'"#$"#&"#&"#&"#$#

*"#*#

!"#&"#*"#&#

+"#$"#$)"#$#

&"#$"#$&"#$#

&"#$"#+"#$"#!"#$"#+"#$#

$"#&"#$&"#&#

)"#$"#$*"#$#

)"#$"#*"#$"#&"#$"#*"#$#

)"#$"#("#&"#("#$#

$"#$"#$!"#$#

&"#$"#$&"#$#

&"#$"#'"#&"#'"#$#

+"#$"#$)"#$#

!"#&"#*"#&#

*"#*#

...and an even bigger one.

What’s wrong with my brain?Human-Computer Interaction and the Stroop Test

Shout out the name of the color from top to bottom, left to right

Shout out the words from left to right, top to bottom.

Shout out the color of the words from left to right, top to bottom.

• To build good user interfaces we need to understand how we process information in our brain.

• The test you have just done is the Stroop Test - many find it very difficult.

• Artificial Intelligence

• Cognitive Science

• Psychology

• Many disciplines can come together

Why does this matter?

Running TogetherSorting, Data Structures, and Parallel Computing

• Sorting numbers (or any data) is a really important problem in computers.

• How do computers do things faster?

• We could figure out a better way of doing the calculation (algorithm)

• We could figure out how to represent the task a little better so we an then figure out a different method (data structure)

• We could do things at the same time (parallel computing)

• We’ll look at a games which we can play in the school year

What’s this all about?

A Sorting Network

72 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Sorting Networks

Prior to the activity use chalk to mark out this network on a court.

!"#$%&'$()"#*+)%*,-(./%0"!

This activity will show you how computers sort random numbers into order using a thing called a sorting network.

1. Organise yourselves into groups of six. Only one team uses the network at a time.

2. Each team member takes a numbered card.

3. Each member stands in a square on the left hand (IN) side of the court. Your numbers should be in jumbled order.

4. You move along the lines marked, and when you reach a circle you must wait

for someone else to arrive.

5. When another team member arrives in your circle compare your cards. The person with the smaller number takes the exit to their left. If you have the higher number on your card take the right exit.

6. Are you in the right order when you get to the other end of the court?

If a team makes an error the children must start again. Check that you have understood the operation of a node (circle) in the network, where the smaller value goes left and the other goes right. For example:

We compare numbers at the circles, smaller go one way, larger in the other

How does it work?

72 Photocopiable for classroom use only.

© 2005 Computer Science Unplugged (www.unplugged.canterbury.ac.nz)

Sorting Networks

Prior to the activity use chalk to mark out this network on a court.

!"#$%&'$()"#*+)%*,-(./%0"!

This activity will show you how computers sort random numbers into order using a thing called a sorting network.

1. Organise yourselves into groups of six. Only one team uses the network at a time.

2. Each team member takes a numbered card.

3. Each member stands in a square on the left hand (IN) side of the court. Your numbers should be in jumbled order.

4. You move along the lines marked, and when you reach a circle you must wait

for someone else to arrive.

5. When another team member arrives in your circle compare your cards. The person with the smaller number takes the exit to their left. If you have the higher number on your card take the right exit.

6. Are you in the right order when you get to the other end of the court?

If a team makes an error the children must start again. Check that you have understood the operation of a node (circle) in the network, where the smaller value goes left and the other goes right. For example:

Kate will demonstrate it with me...

Coloring InGraph Coloring, Combinatorics and Complexity Theory

What’s it about?

• A travel game for children: print out lots of maps (like the one on the right) and give your child four different crayons - and no more.

• For every map you give them, they should be able to color it so that no two countries that have a common border have the same color.

• Simple, but a very deep problem, which we’ll discuss a little shortly. But first...

The Poor Cartographer

He can’t afford very many colors!

Instructions: Color in the countries on this map with as few colors aspossible, but make sure that no two bordering countries are the samecolor.

From “Computer Science Unplugged”

c!Bell, Witten, and Fellows, 1998

Page 138

Kate - can you color this map with two colors? It might be difficult.

Instructions: Color in the countries on these maps with as few colorsas possible, but make sure that no two bordering countries are the samecolor.

From “Computer Science Unplugged”

c!Bell, Witten, and Fellows, 1998

Page 139

These maps can be coloured with three colors only.

• What if two children colored a map together - one tried to use very few colors, and other didn’t care, how many crayons do we need?

• We know 33 is enough, but it is believed at most 10 are needed. Nobody has proved it!

• Empires - two maps, a country of each is paired with a country from the other. Nobody knows how many colors we need!

Why is this deep?

• Four colors are always enough: conjecture in 1852, proved in 1976!

• Number of choices grows quickly as the number of countries increases, e.g. 50 countries in 1 hour; then 1 more country would take 4 hours; 10 more countries requires one year!

• The fundamental open question in computer science is: “Does P=NP?” We don’t know!

Why is this deep?

Card Flip MagicError Detection and Correction

• Kate put down 5x5 cards.

• My additional cards were placed to ensure that the number of pink cards in each row and column were even.

• When Kate changed something, my cards told me exactly what she did.

• Automatic error-checking and correcting key in finance, communications & security.

The Secret

What about actually using a computer, like?Programming stories, games, music and art for children

scratch - http://scratch.mit.eduProgramming stories, games, music and art for children

!"#$"%&'()*$+'!,-.&!"#$%&'()*"+,-).,)"/01)"

2$*"(3)"4$1-5067

Divide-n-ConquerAlgorithms

This book designed by

Computer Science Unplugged is licensed under a Creative Commons Attribution-Noncommercial-No!Derivative Works 3.0 License.

csunplugged.org orangestudio.co.nz

Credits

IV

‘Twas ten to midnight on December 24th and all was not well in the far, far North.

V

Some little elves were wrapping a thousand and twenty four toys, roller skates for a thousand and twenty four good girls and boys.

VII

At ten to midnight the elves called Saint Nick, tonight, all the boxes had been filled extra quick. Saint Nick was thrilled, “right then, fill up thesleigh, a thousand and twenty four boxes and weʼre on our way.”

VIII

Then Mrs. Christmas burst in through the doors “Where are your dirty socks, Santa Claus?”

IX

A young elf cried, “Santa, I dropped your dirty sockses in one of the thousand and twenty four boxes!”

XI

“Quick, unwrap every single box! Iʼm not leaving ʻtil you find those socks!” “Sorry, Santa,” said the supervisor elve, “us workers are all union, and we finish at twelve.”

XIII

Said Santa, “No need to be unpleasant, Iʼve got a big pair of scales, just weigh each present. Theyʼll all weigh the same when you put them in each bucket, except for one, and that oneʼs the culprit!”

XV

“With all due respect,” replied the supervisor elf, “Itʼll take a jolly long time, and you can do it yourself. If we could make one comparison every second, weʼd be here ʻtil twelve-oh-seven!”

XVI

A little elf piped up: “I’ve got an idea! We just need to use divide and conquer here.

XVII

Put half the boxes on that scale, and half the boxes on this, whichever side goes up, that pile we dismiss!”

XIX

The supervisor elf, with an unimpressed gaze, pointed out, “weʼll still be here for days. Youʼve narrowed it down to five hundred twelve, Hardly any help from this little elve.”

XXI

“Wait,” said the elf, only beginning his campaign, “watch what happens when we halve it again.” So they halved it again, and now their fix was narrowed to two hundred and fifty six.

XXII

Then, after their third comparison of weight, their problem was reduced to a hundred twenty eight.

XXIII

Then sixty four,

XXV

then thirty two...

XXVII

sixteen...

XXIX

eight...

XXXI

four...

XXXIII

two...

XXXV

...itʼs true! On the tenth comparison, with much joy, this elf had found the erroneous toy. A job that couldʼve gone well beyond the time limits took just a matter of minutes.

XXXVII

So the gift was replaced, the elves went home, and Santa was set for his world-wide roam. No poor child, far or near, will have to smell Santaʼs dirty underwear!

XXXIX

But first the little elf was approached by Saint Nick, “Where did you learn your clever trick?” The little elf replied “On magic I make no reliance, all I need to use is a little computer science.”

XL

!"#$%&'

Teaching the Principles of Computing to Primary-Aged Kids

Professor Barry O’Sullivanand Kate O’Sullivan (Age 9)