Syntax is the set of rules about how to use a particular language. In the same way that English has rules, so do programming languages.
Program statements have to be used in certain ways for the computer to recognise them. For example, in Python '
print ("Hello World") exactly as it is shown here, you will get a syntax error.
Some programming languages have been developed to help avoid syntax errors. Scratch is a programming language that is built out of visual blocks rather than written language. This avoids syntax errors by removing the need to type in statements.
A statement is a single action in a computer program.
In a recipe for making a sandwich, a statement could be written as 'place bread down' or 'spread butter'. A simple statement in a computer program could be this one, written in Python:
print ("Hello World")
Statements can be more complex and contain many other smaller elements. Here is another example in Python:
if (c!="q") or (c!="quit") : print (“alert”)
In a computer program, statements might include some of the following actions:
Expressions are used within statements when working with values. For example, 2+2 is an expression that returns the value of 4. In a computer program, an expression to work out your age might look like this: