Key Programming Concepts
Periodic Table
In a program, a variable holds a value in memory. This value can change.
In a program, a constant holds a value in memory. This value cannot change.
A set of instructions that are executed in order, one at a time..
Using a loop in a program to repeat the execution of a block of code several times.
Branching a.k.a selection is when when an if statement is used to decide if a block of code needs to be executed.
A data type for whole numbers e.g. 7 or -200
A data type for decimal numbers e.g. 3.14
A data type for text: a string is a collection of characters.
A data type for True or False values.
A count-controlled loop that repeats a section of code a fixed number of times.
A condition-controlled loop that repeats a section of code while a condition is true.
A condition-controlled loop that repeats a section of code up until a condition is met.
When a condition is checked to decide if a block of code will be executed.
An alternative to IF, ELSE IF code used to check multiple possible values of a variable.
Retrieving a user input e.g.
username = INPUT("Enter your username")
When a program produces an output such as displaying a message on screen. e.g.
PRINT("Game Over")
Converting a value from one data type to another using functions such as str(), int() or float().
A range of techniques used to manipulate text/strings using functions such as UPPER(), LOWER() to change the case of a string, LENGTH() to find out the number of characters of a string, LEFT(), RIGHT() and SUBSTRING() to extract characters from a string.
String concatenation: joining two strings together. e.g.
PRINT("Hello " + playerName)
= is the assignment operator used to change the content of a variable. e.g.
score = 10
+, -, *, /, ^ (to the power of), DIV (quotient, whole division), MOD (remainder) are the main arithmetic operators.
==, !=, <, <=, >, >= are the main comparison operators.
AND, OR, NOT are the main Boolean operators.
When a loop or an if statement is used within another loop or if statement.
When multiple values are stored under one identifier. e.g.
scores = [5,9,8,8,10,3]
When multiple values are stored under one identifier. An array has a fixed size. e.g.
days = ["Mo","Tu","We","Th","Fr","Sa","Su"]
A record is a collection of fields used to store multiple values under one identifier. e.g.
player.firstname="James"
player.lastname="Bond"
player.score=7
A subroutine/subprogram that returns a value. A function has a unique name (identifier) and can take parameters. e.g.
calculateSquareArea(width)
A subroutine/subprogram that does not return a value. A procedure has a unique name (identifier) and can take parameters. e.g.
displayMessage(text)
Validation checks/routines are used in programs to make systems more robust. User inputs are checked to ensure that these inputs are valid: e.g. a password should be at least 8 characters long, a username should not be empty, an e-mail address should contain an @ sign, a score should be a positive integer, etc.
The purpose of testing is to
- Check that the system/code is meeting the user requirements and producing the required outputs.
- Try to find bugs in the code.
When the syntax of the code is invalid due to a spelling mistake, a missing bracket or speechmark, etc.
A code with a syntax error will not compile.
When the code does compile (correct syntax) but does not produce the expected output.