Integer, Real, Boolean, Character and String (AQA GCSE Computer Science): Revision Notes
Data types: Integer, real, boolean, character and string
What are data types?
When you write computer programmes, you need to store different kinds of information in the computer's memory. Think of data types as categories that tell the computer what kind of data you want to store and how much memory space it needs to reserve for that information.
For GCSE Computer Science, you need to understand five essential data types that form the building blocks of most programmes.
Understanding data types is fundamental to programming because it determines how the computer interprets and processes your data. Each data type has specific characteristics and uses that make it suitable for different kinds of information.

The five main data types
Integer
An integer is a data type used to store whole numbers. These can be positive numbers, negative numbers, or zero, but they never have decimal points or fractions.
Integers are perfect when you're counting things or keeping track of scores, ages, or quantities where you don't need fractional parts.
Code Example: Using Integers
Here are some examples of how integers might be used in a programme:
score ← 25
highScore ← 100
numOfAttempts ← 0
In this example, all three variables (score, highScore, and numOfAttempts) are storing integer values because they're all whole numbers without decimals.

Real (floating point numbers)
The real data type is used when you need to store numbers that include decimal points or fractions. These are sometimes called float or floating point numbers because the decimal point can "float" to different positions depending on the number.
Real numbers are essential for measurements, prices, percentages, or any calculation that might result in a fractional answer.
Code Example: Using Real Numbers
price ← 19.99
fastestTime ← 9.983
score ← 17.0
Notice that even though 17.0 has a decimal point, it's still considered a real number rather than an integer because of how it's written in the code.
Boolean
Boolean variables are quite special because they can only store two possible values: True or False. Think of them like a light switch - it's either on or off, never somewhere in between.
Boolean values are incredibly useful for storing the results of conditions or keeping track of yes/no situations in your programmes.
Code Example: Using Boolean Values
sorted ← False
LoggedIn ← True
You'll often use Boolean variables to control what happens next in your programme based on whether certain conditions have been met.
Character
A character represents a single letter, number, symbol, or even a space from the computer's character set. When you want to store just one character in a variable, you must put quotation marks around it to show the computer that it's a character value, not a variable name.
Examples of characters include letters like 'H' or 'z', numbers like '7', symbols like '&', or even a space ' '.
Code Example: Using Characters
a ← 't'
b ← '4'
c ← '%'
d ← ' '
Remember that the number '4' as a character is different from the integer 4 - the character version is treated as text, not as a number you can do maths with.
String
A string is a collection of characters grouped together, typically used for storing names, addresses, messages, or any other text-based information. You can think of a string as a sentence or word made up of individual characters.
Just like characters, strings must be enclosed in quotation marks when you assign them to variables. Interestingly, strings can contain numbers and symbols too, but when they're part of a string, they're treated as text rather than values you can calculate with.
Code Example: Using Strings
a ← 'the colour blue'
b ← '47 times'
c ← '95% increase'
d ← 'p@55w0rd'
The key difference between characters and strings is that characters hold exactly one item, while strings can hold multiple characters together.

Programming concepts: Variables and constants
Understanding variables
Variables are like labelled containers in your programme that hold a single piece of data. The brilliant thing about variables is that their contents can change (or vary) while your programme is running - that's why they're called variables!
When you create a variable, you give it an identifier (a name) so you can refer to it later in your programme. Think of the identifier as a label on a storage box that tells you what's inside.
Variables are fundamental to programming because they allow your programmes to work with different data values and respond to changing conditions. Without variables, programmes would be very limited and could only work with fixed, unchanging values.
Rules for naming variables
There are important rules to follow when creating variable names:
Allowed variable names:
- Can contain letters, numbers, and underscores
- Examples: score, max_points, item2
Not allowed variable names:
- Cannot contain spaces (new score would be invalid)
- Cannot start with a number (2ndName would be invalid)
- Cannot use reserved keywords like 'print' which have special meanings
Good variable names should be meaningful and describe what data they're storing. Instead of calling a variable 'x', it's much better to use descriptive names like 'userName', 'totalScore', or 'goalScored'.
Understanding constants
Constants are similar to variables, but with one crucial difference - once you assign a value to a constant, it cannot be changed during the programme's execution. Constants are used for values that should remain fixed throughout your entire programme.
Important formatting rules
When working with characters and strings, you must always use quotation marks around the values. This tells the computer that you're assigning actual text content rather than referring to another variable.
Critical Distinction:
- colour ← 'blue' assigns the text "blue" to the variable colour
- colour ← blue would try to assign the contents of a variable called blue to the variable colour
This distinction is crucial for avoiding errors in your programmes!
Remember!
Key Points to Remember:
- Integer: Whole numbers only (no decimal points) - perfect for counting and scores
- Real/Float: Numbers with decimal points - essential for measurements and precise calculations
- Boolean: Only True or False values - ideal for yes/no conditions and programme control
- Character: Single letters, symbols, or numbers in quotation marks - building blocks of text
- String: Multiple characters together in quotation marks - used for names, messages, and text data