Grade 8 · CAPS · English

Grade 8 Coding and Robotics Study Guide

Complete Grade 8 Coding and Robotics study guide in English, aligned to the CAPS curriculum. 17 chapters with explanations, worked examples, exercises with solutions, and original practice papers with memos.

17Chapters
265Practice Qs & solutions
2Practice papers (short + full)
∞Lifetime access
Unlock this subject Start reading See practice papers

Chapters

Strand 1: Algorithms and Coding

Chapter 1. Binary Numbers and Your First Python FREE

1.1 Welcome to the year of real code

In Grade 7 you learnt to read line-based code next to blocks, to plan with pseudocode and to follow programs with trace tables. This year you write the real thing. Grade 8 Coding and Robotics keeps the same four strands, but the coding strand grows: you will work in the Python shell and the IDE, make decisions with IF and ELIF, command servos by their exact angle, and build towards a project with a serious purpose, a smart food garden that senses the soil and the sun. Before any of that, we start where the computer itself starts: with 1 and 0.

1.2 Binary: how computers count

Everything inside a computer, numbers, words, photos, code, is stored as a pattern of 1s and 0s. Each 1 is a tiny switch that is on, and each 0 is a switch that is off. There is no third option, so computers count in the binary number system: a number system with only two digits.

Binary works exactly like the decimal numbers you know, except that each place is worth double the place to its right instead of ten times as much. Reading from the right, the places are worth 1, 2, 4 and 8. Worked example: the binary number 1011 has a 1 in the eights place, a 0 in the fours place, a 1 in the twos place and a 1 in the ones place. That gives 8 + 0 + 2 + 1 = 11. And it works in reverse: to write the decimal number 13 in binary, take an 8 (13 - 8 leaves 5), take a 4 (5 - 4 leaves 1), skip the 2, take the 1: 13 is 1101 in binary.

Here is the catch: the same bits can mean different things. The eight bits 01000001 are the number 65, but they are also the letter A, because the ASCII table, an agreed list that pairs numbers with characters, says 65 stands for A. The computer cannot tell which one you mean from the bits alone. It needs to know what TYPE of data it is storing, exactly the data types you met in Grade 7: strings, integers, floats and Booleans. This chapter ends with that idea in action.

1.3 The shell: a conversation with Python

Python is the line-based language from Grade 7, and the shell is the window where you talk to it directly: you type one line, press Enter, and Python answers immediately. Two rules first. One: Python is case sensitive. The instruction print works; Print and PRINT do not, because Python treats capital and small letters as different. Two: Python does mathematics with the operators + for addition, - for subtraction, * for multiplication and / for division.

Integers and floats behave just as they did in Grade 7, with one Python habit to learn: division always answers with a float. Type 7 / 2 and the shell answers 3,5, as you would expect, but even 10 / 2 answers 5,0, not 5. The order of operations is the one from Mathematics: brackets first, then multiplication and division, then addition and subtraction. So 2 + 10 / 2 gives 7,0 (the division happens first), while (2 + 10) / 2 gives 6,0.

1.4 When the shell complains: syntax errors

Break the grammar rules of the language and Python refuses to work: instead of an answer, the shell shows an error message. Type 2 +* 3, or leave out a bracket in print("Hello", or misspell print, in every case the line does not run, and the message points at the place where Python got confused. These are the syntax errors from Grade 7 Chapter 5, now live on your own screen. The habit to build from day one: read the message, find the spot, fix it, press Enter again. Every programmer in the world does this daily.

1.5 Variables, input and print

A variable is still the labelled box you met in Grade 7, the shell just makes it real. Type apples = 4 and the box exists; type apples * 3 and the shell answers 12. Two functions complete the conversation. The function print() shows a value on the screen: print(apples) shows 4. The function input() does the opposite: it pauses, waits for the user to type something, and hands over whatever was typed. A two-line program: name = input() stores what the user types, and print("Hello " + name) greets them with it.

1.6 Typecasting: "13" is not 13

One trap hides inside input(): it ALWAYS hands back a string, even when the user types digits. If the user types 7, the variable holds the string "7", text, not a number. And the + operator does different work for different types: for numbers it adds, but for strings it joins. So "7" + "5" gives 75, the two texts glued together, not 12.

The fix is typecasting: converting a value from one type to another. The function int() converts a string of digits into an integer: int("7") + int("5") gives 12. Trace this program, assuming the user types 7 and then 5:

first = input()
second = input()
total = int(first) + int(second)
print(total)

Linefirstsecondtotal
first = input()"7"--
second = input()"7""5"-
total = int(first) + int(second)"7""5"12
print(total)the screen shows 12

Summary

  • Computers store everything as 1s and 0s: binary, the number system with two digits, where each place doubles (1, 2, 4, 8).
  • 1011 in binary is 8 + 0 + 2 + 1 = 11; the decimal number 13 is 1101 in binary.
  • The same bits need a data type: 01000001 is the number 65 or, via the ASCII table, the letter A.
  • The shell answers one line at a time; Python is case sensitive; division always gives a float; order of operations applies (2 + 10 / 2 is 7,0).
  • Syntax errors stop a line from running; read the message, fix the spot, try again.
  • input() always hands back a string; "7" + "5" is 75, but int("7") + int("5") is 12, typecasting converts the type.

Chapter 2. Logic Gates and Truth Tables

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 3. The IDE: Programs You Can Keep

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 4. Decisions: IF, ELIF and ELSE

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 5. Strings, Lists and Turtle Graphics

You will see the full content once you unlock this subject. Unlock for R49.
Strand 2: Robotics Skills

Chapter 6. Servos: Motors That Know Their Angle

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 7. Analogue Control: Potentiometers and Joysticks

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 8. Sensors and the Smart Garden Project

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 9. CAD: Relate Tools, Assemblies and the Part Painter

You will see the full content once you unlock this subject. Unlock for R49.
Strand 3: Cybersecurity

Chapter 10. Hacking, Passwords and Software Threats

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 11. Phishing, Pharming and Spoofing

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 12. Biometric Authentication and Security Levels

You will see the full content once you unlock this subject. Unlock for R49.
Strand 4: Application Skills

Chapter 13. Spreadsheets 1: Sorting, Filtering, COUNTIF and SUMIF

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 14. Spreadsheets 2: Conditional Formatting and Charts

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 15. HTML Links and CSS Fundamentals

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 16. The Website Project

You will see the full content once you unlock this subject. Unlock for R49.

Chapter 17. Networks and the Internet vs the WWW

You will see the full content once you unlock this subject. Unlock for R49.

Practice papers

Grade 8 Coding and Robotics: Term 2 Short Practice Paper (first half) 30 marks · 30 min
Grade 8 Coding and Robotics: Term 2 Full Practice Paper (first half) 60 marks · 60 min
Grade 8 Coding and Robotics: Term 4 Short Practice Paper (full year) 30 marks · 30 min
Grade 8 Coding and Robotics: Term 4 Full Practice Paper (full year) 60 marks · 60 min
Term 2 Exam: Advanced 40 marks · 60 min
Term 4 Exam: Advanced 40 marks · 60 min
Grade 8 Coding and Robotics: Term 3 Test 50 marks · 60 min

Sample questions from this subject

  1. Inside a computer, the binary digits 1 and 0 represent ...
  2. What is the decimal value of the binary number 1011?
  3. Python is case sensitive. Which line will the shell accept?
  4. What does the shell answer for 2 + 10 / 2?

Unlock the subject for the full questions, memos and step-by-step solutions.

About this study guide

This Grade 8 Coding and Robotics study guide is written in clear English, following the CAPS curriculum for South African schools. Each chapter starts with the core content, shows worked examples, and ends with exercises whose solutions are already in the guide.