Assignment, Variables, Constants & Sequences
Inputs, Outputs & Type Conversion
IF Statements & Boolean Operators
Nested Selection and Iteration
WHILE, REPEAT-UNTIL Loops
Validation and verification
Validation and authentication routines
High-level & Low-level languages
Assemblers, Compilers & Interpreters
Data can be stored in many different forms and the proper term for these forms is ‘data types’.
A computer uses special internal codes to keep track of the different types of data it processes.
Most programming languages require the programmer to declare the data type of every data object.
It is these forms that determine what actions, for instance searching, sorting or calculating,
can be performed on the data when it is held within a program or field of a database or a spreadsheet.
The most common data types you will have used are called primitive data types.
Primitive data types are predefined types of data that are supported by the programming language.
Table of the most common primitive data types
Integer data types deal with whole numbers, not decimal numbers, which use a different data type.
An integer is a whole number (not a fractional number) that can be positive, negative or zero.
An example of integers could be: -9, 3, 5, 8, 98, and 5103.
In python when we want to convert a variable (cast) to an integer data type we would do the following:
In mathematics which of the following are integers?
6, -7, 2.6, 10, 4.5, 17, 17.0
A real data type contains numeric data in a decimal form. It is used in situations where more accurate information is required than an integer can provide.
But real data types cannot store the actual measurement symbol (km, kg, etc.) or the units of measurement, for instance kilometres or metres
per second. If you want to use a real data type, you must remember to add the measurement symbol separately and print the units after the field
displaying the data type.
In python when we want to convert a variable (cast) to a real data type we would do the following:
What are the differences between real and integer data types?
The Boolean data type represents the values of true / false or yes / no. The primitive data type of a Boolean is logical.
Boolean logic is a type of mathematical comparison. It is used to evaluate true or false. This may be new to you but it is not
difficult to understand. Think about binary numbers. The lights could be on = 1 or off = 0.
Boolean logic evaluates every expression to either true or false.
Write the following sentences as a Boolean expression:
A string or text data type is capable of holding any alphanumeric character, whether it is text, a number or a symbol.
It is also capable of storing non-printable characters such as carriage returns as well as punctuation characters and spaces.
The data contained within a string data type can either be pure text or consist of a combination of letters, numbers and symbols.
It is important to note that when you use string data types to store numbers, you cannot perform any sort of mathematics on them.
The sort of numbers that you would normally store as string data types would be things like telephone numbers where they often start
with a zero - if you stored them as an integer, the zero would be deleted (remember an integer cannot have a point, so 07 is stored
as 7). As you never want to perform mathematical calculations on a telephone number, the string option is fine.
In python when we want to convert a variable (cast) to a string data type we would do the following:
The date / time data type is obviously used to store dates and times. The tricky aspect of this data type is that both dates and
times can appear in many different forms. Also, some countries have different methods of representing the date, such as:
What data type would you use to store each of the following values?
Which of the above values could not be cast into the data type suggested when using python?