Basic Programming Concepts (AQA GCSE Computer Science)
Revision Note
What is a programming concept?
A programming concept, also known as a construct, determines the order in which lines of code are executed
They control the logic and behaviour of code
There are three core programming constructs:
Sequence
Selection
Iteration
Sequence
What is sequence?
Sequence refers to lines of code which are run one line at a time
The lines of code are run in the order that they written from the first line of code to the last line of code
Sequence is crucial to the flow of a program, any instructions out of sequence can lead to unexpected behaviour or errors
Example
A simple program to ask a user to input two numbers, number two is subtracted from number one and the result is outputted
Line | Python |
01 |
|
02 |
|
03 |
|
04 |
|
05 |
|
06 |
|
A simple swap of line 01 and line 02 would lead to an unexpected behaviour, the user would be prompted to input information without knowing what they should enter
Selection
What is selection?
Selection is when the flow of a program is changed, depending on a set of conditions
The outcome of this condition will then determine which lines or block of code is run next
Selection is used for validation, calculation and making sense of a user's choices
if... then... else... statements are used when you test conditions sequentially
Example
Concept | Pseudocode | Python |
---|---|---|
IF-THEN-ELSE |
|
|
Nested Selection
What is nested selection?
Nested means to be 'stored inside the other'
An example of nested selection is one IF statement inside of another
It is worth noting that iteration can be nested as well and this can be seen in the iteration revision note
Examples of nested selection
Last updated:
You've read 0 of your 10 free revision notes
Unlock more, it's free!
Did this page help you?