G6 T3 Notes 0860
G6 T3 Notes 0860
value1 = INPUT
value2 = INPUT
result = value1 + value2
print(result)
value1 ReadLineFromUser
value2 ReadLineFromUser
Printout value1 + value2
Now give each pair a list of constructs and ask them to identify a A valid pseudocode statement for ‘input’ could be
number of different ways that they can be written. For example, input, enter, read from user, type data,
ask the pairs to write pseudocode commands to either input or read line, read line from user.
output an item of data.
While all of these examples are valid pseudocode,
Ask the pairs for their answers and create a list of the valid Cambridge have created pseudocode guides in support
possibilities, identifying examples that would be appropriate in of the IGCSE, AS Levels and A levels in Computer
pseudocode because they clearly demonstrate that data is input Science. You can view these pseudocode guides on,
and because they are concise. and download them from, the Cambridge International
School Support Hub. Find them under the ‘teaching
Display a pseudocode algorithm and ask learners to follow it to and learning’ section for each of the Computer Science
identify the output for a given input. An example algorithm could syllabuses.
be:
INPUT name
INPUT favouriteColour
INPUT favouriteFood
OUTPUT "Hello ", name, " your favourite
food is ", favouriteFood, " and your
favourite colour is ", favouriteColour
Resources:
• prepared sequences of steps that are presented as
structured statements
• prepared sequences presented as pseudocode.
8CT.02 Follow flowcharts Gather learners’ existing knowledge and understanding of
and pseudocode conditional statements by asking:
algorithms that use What is selection?
conditional statements. Elicit that selection is an instruction within an algorithm where a
decision is made about whether to run a piece of code or not.
Then ask:
How is selection usually written in programming?
Elicit that it is usually written as a question, or a comparison, that
results in ‘true’ or ‘false’.
Ask:
What are the key words used in conditional statements in
programming?
Answer: IF, THEN, ELSE
What are the different symbols that can be used for
comparisons?
Answer: >, <, >=, <=, <> = <> or != are both acceptable for not equal to.
Learning objectives Suggested teaching activities and resources Additional notes
= or == are both acceptable for equal to.
Put learners into pairs and give them a series of flowcharts that Learners should already be familiar with following
use conditional statements. For example: conditional statements in flowcharts but, if they are not,
begin with an introduction to the diamond selection
statement, and explain that it has ‘yes’ and ‘no’ arrows
which are followed depending on whether the response
to the question is true or false.
Ask the pairs to follow the algorithms, with different input data,
and identify the outputs.
Display an example of pseudocode, to suit Python, for an IF This pseudocode is one way of presenting IF THEN
statement. For example: ELSE statements. There are other ways such as:
if condition: IF condition THEN
Code to run if true Code to run if true
else: ELSE
Code to run if false Code to run if false
Explain that this shows the IF command, followed by the ENDIF
condition, then a ‘:’. All of the code that follows the ‘if or
condition:’ is indented and only runs if the condition is true. If (condition)
Then
Also explain that the else: needs to be aligned with the IF, and Code to run if true
the code underneath is also indented, and that this is the code Else
that will run if the condition is false. Code to run if false
Learning objectives Suggested teaching activities and resources Additional notes
endif
Return learners to their pairs and give each pair a series of
pseudocode algorithms that make use of selection (IF, THEN,
ELSE) statements. Examples could include:
Input Value1
Input Value2
if Value1 >= Value2:
OUTPUT Value1
else:
OUTPUT Value2
Ask the pairs to follow the algorithms, using different sets of data,
and to work out what they do. They should also identify the three
different parts of the condition statement in each program. These
are:
• the condition
• the code that is run when the condition is true
• the code that is run when the condition is false.
Resources:
• prepared flowcharts that include conditional statements
• prepared pseudocode that includes conditional
statements.
8CT.07 Predict the Put learners into pairs and give them a copy of a flowchart. Ask
outcome of algorithms and them to read the algorithm and its steps. An example flowchart
test that they meet those might be:
outcomes.
Provide two values for input, such as 4 and 2. Ask the pairs to
predict what the output will be without using the flowchart. Ask
them to then use the algorithm and check if their answer is
correct. They should predict that the output is 2. Repeat this with
different values.
Learning objectives Suggested teaching activities and resources Additional notes
Repeat this process with different algorithms in different formats, Example algorithms:
for example: Output a message depending on the age of the user:
• pseudocode age = input("Enter your age")
• written as a list of instructions if age < 18:
• an actual program. print("You are a child")
The algorithms could: else:
• output a message depending on the age of the user print("You are an adult")
• output a grade depending on the mark entered
Output a grade depending on the mark entered:
• represent a calculator
• represent a computer game where the character moves
and speaks different phrases depending on the input.
Now put learners into pairs. If possible, they should have the
opportunity to work with a partner that they haven’t yet worked
with during this activity.
Learning objectives Suggested teaching activities and resources Additional notes
Give each pair a description of a problem for which a computer
program needs to be written in order to solve it. The problems
should be fairly large so that the pairs can focus their discussion
on splitting the problem into sub-problems, rather than starting to
focus on how the program will actually work.
Resources:
• prepared tasks, scenarios and problems for learners to
decompose.
Learning objectives Suggested teaching activities and resources Additional notes
8CT.09 Know how to Introduce this activity by displaying the word ‘constant’ and If you introduce constants using a text-based language,
develop algorithms that asking: note that Python does not support constants. In Python,
use at least one constant. What does this word mean? although a value can be intended as a constant, it is
Elicit that a constant is something that stays the same and cannot still possible to change it.
change.
Ask the pairs to share their algorithms and to explain how they
identified, declared and used the constants. During these
discussions, check individual learner’s understanding of
constants by asking questions such as:
What is a constant?
Answer: A space in memory that stores a value that
cannot be changed while the program is running.
Why do you use a constant instead of a variable?
Answer: To avoid accidental changes. To allow you to
change the value once so it updates it everywhere that it
is used.
Resources:
• prepared algorithm descriptions that require constants.
8CT.04 Explain the need Introduce this activity by asking learners to consider the following
for searching algorithms. questions:
When did you have to search for something?
8CT.05 Describe and use
What were you trying to find?
linear searches.
How did you search?
Hold a class discussion to gather a range of responses. Learners
should describe the different times they may have searched and
how they approached it, such as:
• looking for lost keys by looking through each place in
each room one at a time
• looking for a file in a computer by using the search
function or checking each folder in turn.
Provide some examples of scenarios where a searching As learners have not yet learned about arrays or lists,
algorithm might be needed, for example: they may benefit from seeing a table with data, such as:
• finding the smallest item in a list
Learning objectives Suggested teaching activities and resources Additional notes
• finding the largest item in a list They can then consider how they would search this
• looking for a specific record in a file data for a specific value.
• finding a special event
• finding an event that happened on a specific date.
Put learners into pairs and ask them to discuss what they would
do to find the answers.
Ask each pair to feed back on their discussions and support the
class towards agreeing a process of checking each item in turn
until they find the item that they are searching for.
Put learners into small groups and give each group a set of cards
with numbers on, for example playing cards. Ask the groups to
place their cards face down and then search for a specific value
by performing a linear search. They will need to turn one card
over at a time, starting with the first one. If they find the number
they are looking for, they stop. If the card is not the one that they
are looking for, they put it back face down and check the next
one.
Ask each group to write a sequence of steps, presented as an This will not be expected in pseudocode or a flowchart
algorithm, to instruct someone else to perform a linear search. but in sentences, for example:
They should swap their algorithms with another group and then • Look at the first card.
test each other’s algorithms using the cards. o If it is it the value you are looking for, stop.
Learning objectives Suggested teaching activities and resources Additional notes
oIf it is not the value you are looking for, put the
The groups should make any necessary corrections based on the
card back face down so you cannot see it.
feedback from other groups. Each group member should then
o Turn over the next card.
write a personal copy of the final version. They should annotate
this with their own notes about searching algorithms, and linear • Repeat until you find the required card.
searches in particular. Ask the following questions to help them to
structure their notes:
What is a searching algorithm?
Answer: a series of steps that looks for specific data in a
set of data
Why are searching algorithms needed?
Answer: to find data within a set of data
Give an example of a searching algorithm.
Answer: a linear search
How does a linear search work?
Answer: each item is checked in turn, starting with the
first
Resources:
• example scenarios showing when searching algorithms
may be used
• playing cards, or similar
Unit 8.3 Programming
Learning objectives Suggested teaching activities and resources Additional notes
8P.01 Outline the purpose of Introduce this unit by holding a class discussion about the purpose of Make sure that learners understand the
program libraries. libraries. Ask the following questions to guide the discussion: important difference between book and
Have you ever been to a library? program libraries:
8P.03 Identify and know how
to use library functions in
What does a library allow you to do? • if you borrow a book from a book library,
Why do you use a library? you need to return it after the set period
text-based programs.
Elicit that the purpose of a library is to enable readers to borrow and of time
read books for a set period of time, without paying a fee. • if you use code from a program library,
you can use it indefinitely.
Link this definition to program libraries in computing. Explain that
program libraries contain pre-written and tested modules, or self-
contained programs, that can be called by another program. Program
libraries save programmers time in writing and testing newly created
functions. Libraries also allow less experienced programmers to
include complex things that they may not yet be able to create for
themselves. Therefore, using libraries in this way can simplify the
whole programming process.
Introduce learners to a Python library, for example random or math. You may need to introduce the concept of
Demonstrate how to import the library into a program, for example: random numbers at the beginning of this
from random import random activity. The purpose of random numbers is to
import math generate random events, select random
choices or make decisions, such as which
Put learners into pairs and give each a description and example of at move a computer should make during a game.
least one library function. For example, from random: Explain that truly random numbers do not exist
randomNumber = random.randint(0, 100) in computers, because there is always an
The 0 is the smallest number that will be randomly generated, the 100 algorithm within the operating system to
is the largest number that will be randomly generated. generate them.
Learning objectives Suggested teaching activities and resources Additional notes
Demonstrate how to import the library and how to use its function. Regardless of which library you use, random
Then set each pair a series of problems that will enable them to or math, learners will benefit from a short
experience using the library for themselves. For example: explanation of the other as this will help them to
• generate a random number between 1 and 10 visualise what different libraries can do.
• generate a random number between 1 and 4, output a different
message depending on the number selected
• simulate the roll of a dice (between 1 and 6)
• simulate a Magic 8-Ball game, where the user asks a question,
then one of a series of five answer options (yes, no, maybe,
not sure, try again) is output; the answer will be determined by
random numbers between 1 and 5.
roundDown = math.floor(2.66)
Where the number in the brackets is rounded down to the
nearest whole number (integer).
value = True
if not value:
print("False")
Learning objectives Suggested teaching activities and resources Additional notes
else:
print("True")
Put learners into pairs and give them a series of programs to write that
use the conditional statements if and else and progress to
conditional statements AND, OR and NOT. For example:
1. Take a number as input from the user and check whether it is
greater than 10. Repeat by checking if it is less than 10.
Answer:
numberInput = int(input("Enter a number"))
if numberInput > 10:
print("Greater than 10")
else:
print("Less than or equal to 10")
2. Ask the user a question and output whether their answer was
correct.
Answer:
answer = int(input("What is 2 * 2?"))
if answer == 4:
print("Correct")
else:
print("Incorrect")
5. Take two numbers as input from the user and output the
number which is larger.
Answer:
first = int(input("Enter a number"))
second = int(input("Enter a number"))
if first > second:
print(first)
else:
print(second)
7. Ask the user to enter two test results. If either test result is
greater than 90, tell them that they passed.
Answer:
Learning objectives Suggested teaching activities and resources Additional notes
result1 = int(input("Enter result 1"))
result2 = int(input("Enter result 2"))
if result1 > 90 or result2 > 90:
print("Pass")
8. Ask the user to enter two test results. If both results are greater
than 90, tell them that they passed with distinction.
Answer:
result1 = int(input("Enter result 1"))
result2 = int(input("Enter result 2"))
if result1 > 90 and result2 > 90:
print("Distinction")
Resources:
• coloured cards for two colours, for example blue and orange.
8P.02 Identify and describe Introduce this activity by asking: Learners should already be familiar with
data types in text-based What is a data type in programming? Integer, Real and String in Computing. If they
programs, including Integer, Answer: data that is put into categories, so the program knows are not, introduce these as:
Real and Boolean. what is expected • Integer stores whole numbers
8P.05 Know how to develop What data types do you already know? • Real stores decimal numbers
text-based programs using Answer: Integer, Real and String • String stores characters that can include
data types, including Integer, What is the difference between an Integer and a Real number? letters, symbols and numbers that cannot
Real, String and Boolean. Answer: an Integer is a whole number, a Real number is a be used mathematically.
decimal number Learners may encounter slightly different
definitions of Integer and Real in Mathematics,
Learning objectives Suggested teaching activities and resources Additional notes
What is a string? but should understand the definitions above for
Answer: one or more characters that can include letters, Computing.
symbols and numbers that are not used in mathematics
calculations, such as telephone numbers or credit card
numbers.
Introduce the concept of a Boolean data type as ‘true’ or ‘false’ We usually spell ‘Boolean’ with a capital B.
because it can only be one of two values. Demonstrate this by saying Explain that this is because it is named after a
a statement such as person: George Boole.
‘10 is less than 11’
and agreeing that this is ‘true’.
Ask:
What else in programming only has two values?
Answer: binary is 1 or 0
Support learners to associate the Boolean data type ‘true’ with the
binary number ‘1’, and ‘false’ with ‘0’.
Give learners a table of data and ask them to identify the most Learners often identify any numeric-only values
appropriate data type for each. Here is an example table, with the as being Integer or Real. However, numbers
expected answers in italics : that are not used in calculations, such as
telephone numbers or credit card numbers, will
always be a string. Explain that if the number is
never used in a calculation, it is a string.
Put learners into pairs and give them a set of programs that will
require the use of data of different data types. For example:
1. Ask the user a series of questions that require answers as In Python, for True and False to be recognised
integers, reals and strings. Store whether they answered each as Boolean they need to be True or False.
question correctly in a different variable as True for correct, This is case sensitive.
and False for incorrect.
Answer:
answer1 = int(input("What is 1 + 2?"))
if answer1 == 3:
answer1Result = True
else:
answer2Result = False
answer2 = float(input("What is 3 / 2?"))
if answer2 == 1.5:
answer2Result = True
else:
answer2Result = False
answer3 = input("Enter True if 2 = 3? Or False
otherwise")
if answer3 == "True":
answer3Result = True
else:
answer3Result = False
if result == True:
print("Yes you entered True")
else:
print("Oh no, you did not enter True")
3. Design a questionnaire and write a program to ask the user the When taking input from a user, Python will store
questions and store their answers. all data as a string. To convert it to an integer
Answer: the code int() needs to be used, for example:
firstName = input("Enter your first name")age answer = int(input("What is 1 +
= int(input("Enter your age")) 2?"))
pocketMoney = float(input("Enter the amount of For a real number, the key word float is
pocket money you get")) needed instead of int.
likeGames = input("Enter True if you like
video games") To check for Boolean data, the value would
if likeGames == "True": need to be compared to the String value. It will
likeGames = True not actually store it as a Boolean data type
else: unless done manually, for example:
likeGames = False result = input("Enter True or
False")
4. Write a program that displays some data and asks the user for if result == "True":
the most appropriate data type for each. Output whether they result = True
are correct or incorrect. This would not be done practically in
Answer: programming, but it is good experience for
print("What data type is more appropriate learners to manipulate the values.
for:")
answer1 = input("True or False") Depending on your context, you may need to
if answer1 == "Boolean":
use a different example to pocket money.
Learning objectives Suggested teaching activities and resources Additional notes
print("Correct") Pocket money can be defined as ‘a small
else: amount of money given regularly to a child by
print("Wrong it is Boolean") an older family member’.
Conclude by asking:
What is the difference between a String and a Boolean data
type?
Support learners to recall that Boolean is only ‘true’ or ‘false’, while a
String can be any combination of characters.
Resources:
• data type table or worksheet
8P.07 Use an iterative Introduce this activity by asking: Learners are likely to have already used
process to develop programs. What do we mean by iteration or repetition? iterative development when writing programs
Elicit that it is about doing the same thing more than once. Then ask: without realising. This is because programs
When you write programs, do you always get them right first rarely work first time and, therefore, they are
time? changed and then tested again.
If not, what do you do when a program is wrong?
Do you always write the whole program in one go, or do you
write a small part and then add to it?
Why do you do it this way?
Put learners into pairs and give them a description of a program that
takes a user’s grades or marks in a range of subjects and then outputs
which subjects they should continue to study. For example, high
scores in Maths and Computing could create an output recommending
that the user continues to study Maths and Computing.
Learning objectives Suggested teaching activities and resources Additional notes
Ask the pairs to discuss, plan and then create their program. Tell them
that they must use the ‘discuss, plan, create’ cycle iteratively until their
program is complete.
Demonstrate a program that only works with some data and not with The second condition is incorrect. It should be
other data, for example: number <= 10. If the user inputs 10, the
number = int(input("Enter a number between 1 program will produce the wrong output.
and 10 inclusive"))
if number >= 1 and number < 10:
print("Success")
else:
print("Wrong")
Demonstrate that testing this program with:
• 5 will output Success
• 15 will output Wrong
• 10 will output Wrong, so it will not work as expected.
Hold a class discussion on why it is not sufficient to test a program Make it clear that not every possibility can be
with one or two examples of test data. Elicit that a range of data tested. Instead, developers need to make a
should be used. reasonable judgement about when they can
state that their program works.
Give learners a blank test table for a program. For example:
Explain that sometimes a program can be
tested with a wide range of data but can still
contain an error that has not been thought of,
such as in a gameplay situation when a
character bumps into an object and can no
longer move.
Put learners into pairs and ask them to use the table to create a test
plan for the program that they looked at earlier in the activity. They
should plan to test it with a range of data, but they should not perform
the test yet. An example of the output from this activity might be:
Learning objectives Suggested teaching activities and resources Additional notes
Ask pairs to share their completed test table with another pair and to
add any further tests that they think are appropriate. The pairs should
then test the program and complete the ‘Actual result’ column.
Resources:
• test table template
• learners’ programs from earlier activities.
8P.11 Know how to develop Check learners’ prior experience of using programmable devices, and Learners may have used beebots and
programs that allow two or support them to recall this experience, by asking: micro:bits in earlier stages. For example, they
more physical devices to What devices do you know how to program? may have given directional instruction to a
interact. What commands can you remember for these devices? movable device or may have programmed
What can you make these devices do? simple traffic -control systems.
Ask learners to access programs they have previously written for the
devices and to discuss in pairs what each line of code does and how it If no example programs are available, give
works. learners an example such as the following,
which uses MakeCode:
Hold a class discussion on the interaction of devices in the 'real world'
by asking:
What devices do you know that interact?
Support learners to suggest examples such as:
• computer to printer
• laptop to mobile phone
• thermostat to heating.
Ask:
How do devices communicate? What do they send?
Elicit that devices send messages in binary and that they could be
transmitted by, for example, cable, wi-fi, satellite or Bluetooth.
Learning objectives Suggested teaching activities and resources Additional notes
Demonstrate how to make two or more devices interact. This will The function and methods will depend on the
depend on the devices that you use, but common methods include: devices used. Some devices may need a
• detecting the movement of another device, for example one physical connection (cable) between them;
device stops moving when another device lights up others may use sensors to detect each other;
• receiving and responding to a signal from another device, for while others may use wi-fi or Bluetooth to send
example a device flashes a light when another device tells it to. messages to each other. Set tasks appropriate
Show learners how to program the device to: for the devices that you are using.
• send a message or signal to another device
• receive a message of signal from another device
• use a sensor to record the action or signal from another
device.
For two devices to interact, learners will need to program both devices
individually.
Learning objectives Suggested teaching activities and resources Additional notes
Put learners into pairs or groups and give them a problem that they
need to create a program to solve. Example problems for micro:bits
could be:
• Device 1 needs to send device 2 a maths question. Device 2
needs to calculate the answer and send it back. Device 1
needs to tell device 2 whether it is correct or not.
• Similar to the problem above, but device 2 outputs the
question, then the user has to input the answer which is sent
back to device 1.
• Device 1 sends signals to device 2 telling it how to move. For
example, the user could input the command to move forward
on device 1; device 1 sends a message to device 2, which
then moves forward.
• Two devices need to move around an area. When they sense
each other nearby, they turn towards each other and flash a
message.
Hold a class discussion to review the learning from this activity. Ask
the following questions to support the discussion:
How did you test your program?
How did you connect your devices?
How did you make sure that the devices communicated? Did
they communicate by cable, wi-fi or Bluetooth?
How did they know what to do?
Did you encounter any problems or errors in the development?
What were they? How did you correct them?
Resources:
• micro:bits
Learning objectives Suggested teaching activities and resources Additional notes
• example code, using Make Code
• problems for learners to solve.