Lesson Objective

To introduce programming in Go and carry out simple mathematics using a program written in Go

More Teaching Time Required

This lesson needs twice the normal teaching time. This is the first lesson that the pupils will need to use a text editor to write the Go program and the command line/terminal window to run the program. It is likely that the pupils will not be familiar with either of these programs.

The text editor and command line are both essential tools that will be used in every lesson. Time should be devoted to showing the pupils how to

  • Start both programs
  • Create a directory
  • How to create a new source code file using the text editor
  • How to save the source code file
  • How to use the terminal to run the program

The phrases “Terminal” is more commonly used in MacOSX or Linux or on a Raspberry Pi. “Command prompt” is largely used on Windows.

These terms, along with “command line,” are largely interchangeable.

Success Criteria

  • I can start a command prompt or terminal window
  • I can start a text editor
  • I can type in a Go program
  • I can run a Go program
  • I understand how to do simple sums in Go

Key Vocabulary

  • Go
  • Programming Language
  • Text Editor
  • Command Prompt
  • Terminal Window
  • Textual
  • Source code
  • Integer

Period of Study

KS2 Emerging

Co2/1.1 design, write and debug programs that accomplish specific goals, including controlling or simulating physical systems; solve problems by decomposing them into smaller parts

Co2/1.2 use sequence, selection, and repetition in programs; work with variables and various forms of input and output

Co2/1.3 use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs

Maths - interger/whole numbers, simple addition, subtraction, multiplication and division

SMSC

Resources/Homework

The pupils will need to have Go installed on the school computers. They will also need a text editor installed. For Windows/MacOS X and Linux they should install Atom. For RaspberryPi they should install liteIDE. See the install guides on the website for more details.

Starter Activity

Numbers are fundamental to a computer so it makes sense to start here.

Computers process data in the form of numbers. From the computer’s point of view everything is a number. The computer uses logic to process the data. It does not matter what the data is. It could be a word processor document, a picture or a music file. These are all just long lists of numbers to the computer.

Each of the rainbow colours can be given a number e.g. red = 1, orange = 2 etc. The computer can then use the numbers to represent the colours

Ask the pupils to do some simple mathematics - addition, subtract, multiplication and division of whole numbers.

Main teaching points

  • Explain that Go has to be typed, in contrast to Scratch.
  • Explain that the files the pupils type are called source code
  • The source code files contain the sequence of Go instructions for the computer
  • Show the pupils how to start a terminal window/command prompt. How you do this depends on which operating system you are using.
  • Show the pupils how to start the text editor, create and save a file. Again this depends on the platform
  • Explain that a whole number is called an integer in Go
  • Explain the program task and ask the pupils to type in and run the program.

For High Achievers

The pupils should understand that a computer can only process numbers.

The pupils should understand that everything is represented as a series of numbers inside the computer.

The pupils should be able to open a terminal window, largely without support.

The pupils should be able to open the text editor, create a source code file and save it, largely without support.

The pupils should be able to type in the numbers program and run it successfully, largely without support.

The pupils should be able to type in the numbers program and run it successfully, largely without support.

For Middle Achievers

The pupils should understand that a computer can only process numbers.

The pupils should understand that everything is represented as a series of numbers inside the computer.

The pupils should be able to open a terminal window, with support.

The pupils should be able to open the text editor, create a source code file and save it, with support.

The pupils should be able to type in the numbers program and run it successfully, with support.

The pupils should be able to type in the numbers program and run it successfully, with support.

For Low Achievers

The pupils should understand that a computer can only process numbers.

The pupils should be able to open a terminal window, with considerable support.

The pupils should be able to open the text editor, create a source code file and save it, with considerable support.

The pupils should be able to type in the numbers program and run it successfully, with considerable support.

The pupils should be able to type in the numbers program and run it successfully, with considerable support.

Plenary

Can the pupils write down the answers to these sums:

15 - 3 - 10 =

20 + 7 - 3 - 8 =

3 * 3 * 3 =

56 / 7 =

Can they work out this

(1 + 2) * (9 - 5) =

Brackets can be used in the program and behave as you would expect.

Search

Featured Lesson

Numbers

What You are Going to Learn?

Computers are used to process data. All data is made up of numbers. Yes, really! Everything is just a bunch of numbers to a computer. These are the only things they understand.

We are going to explain how numbers are used in Go programs. Then we are going to show you how to do type sums in Go.