- [Craig] In this video, we provide you with a basic overview to the programming concepts
that you need to be aware of so that you can answer all the questions in the paper two exam.
Many of these concepts will be gone through in a lot more detail in later videos.
(uplifting piano jingle)
So there are several programming concepts that you're going to need to be aware of.
And you're going to need to be able to write algorithms in the form of flowcharts, pseudocode
and also in Python program code.
You're going to need to be aware of data types and conversion,
structured data types, variables and constants,
sequence, selection, iteration, how to use subprograms,
how to input, process and output data,
and how to handle a number of different library modules.
Now before we dive into overviewing the programming concepts you need to be aware of,
we want to make you aware of the programming language subset from Edexcel Pearson.
This document specifies which parts of Python 3 are required
in order that the assessment can be undertaken with confidence,
and students familiar with everything in this document
will be able to access every part of the paper two assessment.
Also note the exam board states that they will not go
beyond the scope of the programming language subset document
when setting you assessment tasks.
However, you can successfully gain full marks even if you
use ideas or programming concepts that are beyond the scope of the document.
Now these two points are really important because
you will notice here from the front of the paper two exam,
it states that a printed and electronic copy of the programming language subset
must be supplied to you for use during the exam.
Well if Pearson are giving you a document that tells you
exactly what concepts in Python 3 you need to know
and these are the only concepts they will use in the exam
and that you're allowed to use it as a reference guide,
you might as well get used to the document now.
It may be your teacher has already provided this to you,
but if not, ask them for a copy and have it with you
as a reference guide throughout your time in the GCSE course.
It will become invaluable.
So what follows then is an overview of the various programming concepts you need to become familiar with.
As we said at the start, a lot of this material is covered in more detail and depth in later videos in this topic
and also in our videos on topic 6B, programming fundamentals.
However, we must stress there is no substitute for programming practice.
You are not going to learn programming from a book or simply from watching these videos.
To become a programmer, you have to program.
So let's quickly run through an overview of some of these concepts then.
The first is comments, and in Python,
anything after the hash symbol is considered a comment and is ignored by the program.
So next are identifiers.
An identifier is any sequence of letters, digits and underscores but not spaces that start with a letter,
and you can have both upper and lower case.
Identifiers are typically used for naming variables but also for naming procedures and functions.
Next we have assignment, and this is used to set or change the value of a variable.
So you can see a couple of examples here, we have a value on the right,
and we assign that to a variable on the left and the equals is in the middle.
Or we have an expression on the right,
and the result of that expression is assigned to a variable on the left,
again with the equals in the middle.
So here we have my first name becomes equal to the string Craig,
or volume becomes equal to the result of the calculation width times height times depth.
Next we have what are called primitive data types,
and these are the most common data types that you'll be using, especially in early programming,
and they're the integer, real, Boolean and character.
Now variables may be explicitly assigned a data type during declaration,
or variables may be implicitly assigned a data type during initialisation.
We then have what are called structured data types.
A structured data type is a sequence of items which themselves are data types,
and sequences start at zero.
So we have a string, which is a sequence of characters.
We have an array, which is a sequence of items with the same data type,
and we have a record, which is the sequence of items,
usually with mixed data types.
You also need to understand data type conversion.
We use it to transform the data types of the contents of a variable
using things like int, str, float, bool,
and we can convert between any allowable data types permitted.
You'll learn fairly early on how to input information from the user from a keyboard
and how to output data to a display.
The print command outputs data to the screen,
and we can do that in various ways as shown here,
and the input command is used to prompt the user
and then take some input from the keyboard, and combining that with assignment,
we then assign that input to a variable.
You'll need to become aware of one of the most fundamental programming concepts called sequence,
and this is simply the concept that every instruction comes one after the other
from the top of the file to the bottom, executed in order.
You'll need to understand what we mean by blocking.
Now the blocking of code segments is indicated in Python by indentation and subprogram calls,
and using indentation correctly in Python is very important
and is something you're going to become familiar with very early on in programming.
A very important programming concept is selection and again, is one you will learn early on.
Selection allows your program to branch or choose one of two or more different paths depending on some outcome.
The simplest form is just called the if selection statement.
We say if some expression is true then perform a piece of code.
So for example, if age is greater than 18, print you can vote.
We can build on this with if else.
So if you look at the code on the right,
we say if age is greater than 18 then print you can vote,
otherwise or else print you can't vote.
Your code is branching based on a choice.
You can have multiple if elses with the if elif command.
So we could say here if selection is A, print choice A, new.
If selection is B, choice B, open.
If the selection was C, print choice C, save.
If it's anything else, tell the user invalid choice.
Again, these are all ways of getting your program to branch based on the result of an expression.
You also need to be very familiar with the constructs of repetition and iteration.
This is the idea that we could loop a certain number of lines of code
and perform them again and again until some sort of condition is met.
The first is repetition and we use this in Python with what's called a while loop.
So here we carry on executing some code while a given condition is true.
The other form of looping is known as iteration,
and for this, we use for loops.
Now, there are many ways of using for loops in Python,
and you will explore several of them as you go through the course.
We covered subprograms in an earlier video and again,
you have to become comfortable and familiar with using subprograms,
including both procedures and functions.
And then there's all sorts of other concepts as well on top of that,
which are all covered in the programming language subset document,
including arithmetic operators, relational operators,
Boolean operators, file handling,
string manipulation and string formatting, list methods,
how to generate a random number, maths functions, the time module
and also the Turtle graphics module.
As mentioned earlier, we cover a lot of this material in a lot more detail,
which is why we've whizzed through it here,
in later videos in this topic, and especially in topic 6B,
which is all about programming fundamentals.
But we'll state one last time that to become good at programming,
you have to practise programming.
(uplifting piano jingle)