This resource is designed as a quick revision guide and must not be used by students during a NEA where internet access is not allowed. It has not been endorsed by any exam boards. If you spot any mistakes, please let me know and I'll fix them asap.
A function is a named section of code that works something out and returns a value that can be used elsewhere in the code.
Builtin functions are tools within a programming language that you don't have to write from scratch: they just work out of the box.
This website only shows the builtin functions defined in pseudocode.
A string is some text such as "Hello"
The length of a string means how many characters (including spaces, numbers and punctuation) there are in that string
This example createa a string called name and sets it to "Bob". It counts how many characters are in that string and stores the answer (3) into a variable called l
Computers can't think for themselves - they can only follow instructions., so getting them to choose a number that is truely random is not easy. Thankfully, most programming languages have a function that will choose a number for you that appears to be chosen at random.
This example generates a random integer between 0 and 10 and saves it into a variable called r
Most programs need to output text to the user.
This example displays the text "Hello" to the screen
Most programs need to get the user to type in data that controls how the program behaves.
This program asks the user for their name and saves the result into a string variable called name.
Often it's useful to convert a number (integer or real data type) to text (string data type) so that it can be processed or sent as an output later in the program.
This example converts the integer number 1000 to a string containing "1000"
Often it's useful to round a decimal number (real data type) to a whole number (integer data type).
It can also be useful to convert a string representation of a number (e.g. one typed in by the user) to an integer
This example converts the string "1000" to the integer 1000
Often it's useful to convert a string representation of a number (e.g. one typed in by the user) to a decimal number for use in calculations (real data type)
This example converts the string "1.1234" to the real value 1.1234