Introducing Kids to Coding

safaal28

Safa Al-Siaudi

Posted on April 9, 2022

Introducing Kids to Coding

In 2019, I facilitated workshops for the Girl Guides of Canada to introduce young girls to computer science and algorithmic thinking in a fun and playful way. While there are many resources online for beginner coders (Scratch, code.org, Codewars, among others), I've written below two offline tutorials that anyone can use to spark a kids interest and give them the confidence they need to pursue a career in technology if that's what they enjoy.

1. Decrypt the Secret Message

Learning objectives: This activity is an introduction to cryptography where participants decrypt a secret message using Caesar Cipher.

Materials: A secret message that has been encrypted and an encryption dictionary

Time: ~ 15-20 minutes

Suggested age group: 7-11 years old for activity A, 12-17 years old for activity B

Note: This activity is split into two, both of which are of the same nature but activity B is slightly more difficult than activity A

Activity A

We have an encrypted message that is written using numbers where each number represents a letter. Participants will decipher the secret message by converting the number to its respective letter. A dictionary is given to participants indicating which number represents which letter.

For example if A = 1, B = 2, C = 3, ...., Z = 26

The secret message is written as follows:

3 18 25 16 20 15 7 18 1 16 8 25

which would be translated to:

C R Y P T O G R A P H Y

Messages can be of any length and can be full phrases to increase complexity level.

You can ask the kids to create some secret messages of their own. Some examples of words they could encrypt are:

C O M P U T E R S

C H O C O L A T E

I C E C R E A M

Activity B

Here, participants will use a slightly more complex form of encryption called Caesar cipher. Caesar cipher is one of the oldest and most well known ciphers, named after Julius Caesar. The letters are swapped around so that nobody can understand your message except those who you intended to read
the message.

Participants will choose a number between 1 and 25 that will serve as a key and each letter in the alphabet is shifted by that key. For example, if a group chooses the key 3, then their entire alphabet will become:

X Y Z A B C D E F G H I J K L M N O P Q R S T U V W

If a group wanted to write a secret message such as “SpiderMan is the best movie to ever exist” it would become

VslghuPdq lv wkh ehvw prylh wr hyhu halvw

Use the image below for participants to fill in the new alphabet based on the key.

Dictionary

Then, give students a secret message and a key. A secret message can be anything such as "Encanto" or "I love donuts". I created the handout below for participants.

Encrypted words

Once everyone has attempted the handout, you can take them up. The solutions are written below.

Decrypted Words

After the activity, you can debrief with the kids by asking the following questions:

  • How does Caesar cipher work?

  • How can you imagine encryption to be used in the real world/on a day-to-day basis?

  • If someone is trying to decrypt your secret message and knows about Caesar ciphers, will they be able to easily understand the secret message?

  • Can you think of any other way secret messages can be encoded?

2. Go Turtle Go

Materials

  • A computer
  • Python software downloaded onto the computer and an IDE (Integrated Development Environment)

If you do not have Python downloaded, first download Python at python.org, then download the IDE Pycharm.

Suggested age group: 12-17 years old

This introduces participants to programming on a computer using the programming language Python. If Python and Pycharm are already downloaded onto the computer, then no internet access is needed for the rest of the activity. In this exercise, we will use turtle.py which is a great introduction to programming where users get to see what they are doing. Visual programming allows first time users to enjoy programming by trial and error. Encourage participants to try and see what happens when using various instructions and to play around.

If you use PyCharm as your IDE, choose “Create New Project”

At the bottom of the page, click on Python Console.

All code will be written next to the three arrows '>>>' which can also be referred to as the Python Shell.

A screenshot of a Python Console next to a graphic opened by turtle.py that is a white screen with a small turtle in the center

import turtle
ben = turtle.Pen()
ben.shape(“turtle”)

First, we import the turtle.py package, then assign an instance of turtle to any variable name (I named my turtle ben) and then we gave it a pen to draw. We then gave ben a turtle shape.

Next, participants can draw anything with a few commands. For example if they wanted to draw a square, the participant would write:

ben.forward(100)
ben.left(90)
ben,forward(100)
ben.left(90)
ben.left(100)
ben.forward(100)
ben.left(90)

To clear your screen:
ben.reset()

A screenshot of a Python Console next to a graphic opened by turtle.py that contains a square

The values inside two brackets is called a parameter.

Participants can get really creative in what they code and create complex designs.

To add colour, you could write ben.color(“blue”) to make the lines blue. To draw a circle, you could write ben.circle(100)

If participants want to step it up a level, they can make a spiral:

ben.speed(0)
for i in range(50):
  ben.circle(i*3)
  ben.left(10)
Enter fullscreen mode Exit fullscreen mode

A screenshot of a Python Console next to a graphic opened by turtle.py that contains a spiral

After participants are done, you can exit the program by clicking File and then Exit. You can talk to participants about how Python interprets instructions literally. In the tutorial we saw how instructions needed to be procedural and logical. For instance, when we drew a square we needed to turn left before going forward. You can ask the participants questions such as:

  • What are some of the things you can draw using turtle?

  • How did your drawings change when you used different parameters?

  • How did your drawings change when you put different numbers for speed()?

  • How did your drawings change when you put different numbers in a direction (e.g. left(), right(),forward())?

  • What kind of expressions did you use as parameters? E.g. while making a spiral, you could input i*3 as a parameter in circle()

  • What can turtle not do?

💖 💪 🙅 🚩
safaal28
Safa Al-Siaudi

Posted on April 9, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Introducing Kids to Coding
python Introducing Kids to Coding

April 9, 2022