Basic Programming Concepts (AQA GCSE Computer Science)

Revision Note

James Woodhouse

Written by: James Woodhouse

Reviewed by: Lucy Kirkham

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

print("Enter the first number")

02

Num1 = input()

03

print("Enter the second number")

04

Num2 = input()

05

Result = Num1 - Num2

06

print(Result)

  • 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

if-else-if-else-statement-pseudocode-computer-science-revision-notes

Example

Concept

Pseudocode

Python

IF-THEN-ELSE

IF answer == "Yes" THEN

OUTPUT("Correct")

ELSE IF answer == "No" THEN

OUTPUT("Wrong")

ELSE

OUTPUT("Error")

ENDIF

if answer == "Yes":

print("Correct")

elif answer == "No":

print("Wrong")

else:

print("Error")

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

Prgm_Basic Programming Concepts

Last updated:

You've read 0 of your 5 free revision notes this week

Sign up now. It’s free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

James Woodhouse

Author: James Woodhouse

Expertise: Computer Science

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.

Lucy Kirkham

Author: Lucy Kirkham

Expertise: Head of STEM

Lucy has been a passionate Maths teacher for over 12 years, teaching maths across the UK and abroad helping to engage, interest and develop confidence in the subject at all levels.Working as a Head of Department and then Director of Maths, Lucy has advised schools and academy trusts in both Scotland and the East Midlands, where her role was to support and coach teachers to improve Maths teaching for all.