• Scratch: a good basic introduction to programming for beginners that is freely available from MIT. Scratch makes programming easy and fun to learn as it uses visual building blocks. It is useful as an introduction.
• Python: a general purpose, open source programming language that promotes rapid program development and readable code
Declaration and use of variables and constants
A VARIABLE in a computer program is a named data store that contains a value that may change during the execution of the program
A CONSTANT in a computer program is a named data store that contains a value that does not change during the execution of the program.
Basic data types
In order for a computer system to process and store data effectively, different kinds of data are formally given different types. This enables:
• data to be stored in an appropriate way, for example, as numbers or characters
• data to be manipulated effectively, for example numbers with mathematical operators and characters with concatenation
• automatic validation in some cases.
An INTEGER is a positive or negative whole number that can be used with mathematical operators.
FirstInteger = int(25)
FirstReal = float(25)
A variable or constant of type CHAR is a single character.
Gender = ‘F’ or Gender = “F”
A variable or constant of type STRING is several characters in length
TelephoneNumber = ‘44121654331’
FirstName = ‘Emma’
UnRepeatable = ‘@!&&@@##!’
A BOOLEAN variable can have only two values: TRUE or FALSE.
Statements are followed in sequence so the order of the statements in a program is important. Assignment statements rely on the variables used in the expression on the right-hand side of the statement all having been given values
FirstNumber = int(input( ‘Enter First Whole Number: ‘))
SecondNumber = int (input( ‘Enter Second Whole Number: ‘))
Sum = FirstNumber + SecondNumber
print (‘The sum equals ‘, Sum)
It is a very useful technique, allowing data items to be picked out according to given criteria, for example selecting the largest value or the smallest value, selecting items over a certain price, selecting everyone who is male. This is done with the use of if and case statements.
Most programming languages support three types of loop:
• a fixed number of repetitions
• an unknown number of repetitions with at least one repetition, as the condition is tested at the end of the loop
• an unknown number of repetitions which may not be completed at all, as the condition is tested at the beginning of the loop.
Totalling is used with repetition with the total updated every time the loop is repeated.
ReceiptTotal = ReceiptTotal + CostOfItem
Counting is used with repetition with the counter increased by 1 every time the loop is repeated
NumberOfItems = NumberOfItems + 1