Skip to content

a. What You Need To Know

Data types

Data types classify the kind of data a variable can store and the kinds of operations that can be performed on that data.

Choosing the right data type matters because it affects:

  • efficiency
  • memory use
  • the operations available
  • the accuracy of the program

Key Point

Choose the most appropriate data type for the job. Do not store numbers as text unless they really need to behave like text.

Common data types

Data type What it stores Example
Integer Whole numbers 17
Floating point Numbers with decimals 3.14
Boolean True/False values True
Character One symbol 'A'
String A sequence of characters "Iona"

Numeric data

Numeric types are used when calculations are needed. Whole numbers are typically stored as integers, while decimals are stored as floating point values.

Boolean data

Boolean values have only two states: true or false. They are especially important in decision-making and control structures.

Text data

Text data can be stored as individual characters or as longer strings made from multiple characters.


Variables

Variables store data so that it can be accessed, updated and reused during program execution.

Without variables, a program would not be able to remember information once a value had been entered or calculated.

Initialising variables

Initialising a variable means giving it its first value.

Accessing variables

Accessing a variable means retrieving the value currently stored in it.

Storing data in variables

Storing data in a variable means assigning a new value to it.

Think of it this way

A variable is a labelled storage location. The label helps you refer to the value later, and the type helps the computer understand how that value should be handled.


Arithmetic operators

Arithmetic operators are used to perform mathematical calculations.

Operator Description Example
+ Addition a + b
- Subtraction a - b
* Multiplication a * b
/ Division a / b
% Modulus / remainder a % b

These operators are used in formulas, calculations, totals, percentages and many other programming tasks.


Logical operators

Logical operators work with Boolean values and help combine or reverse conditions.

Operator Description Example
AND / && True only if both conditions are true age >= 15 AND age <= 17
OR / \|\| True if at least one condition is true score < 50 OR attempts > 3
NOT / ! Reverses a Boolean value NOT isLoggedIn

Logical operators are especially important in selections and loops.


Conditional operators

Conditional operators compare two values or expressions.

Operator Description Example
== Equal to a == b
!= Not equal to a != b
> Greater than a > b
< Less than a < b
>= Greater than or equal to a >= b
<= Less than or equal to a <= b

These operators are used when programs need to make decisions based on conditions.

Common Error

Be careful not to confuse assignment with comparison. In many languages, = stores a value, while == checks whether two values are equal.


Why these ideas belong together

Data types, variables and operators work as a foundation set.

Students need to know:

  • what kind of data they are storing
  • where that data is stored
  • how that data can be changed or compared

Once those basics are secure, it becomes much easier to build selections, loops and larger solutions.


What this means for your folio

In a folio task, you should be able to:

  • choose suitable data types for each piece of data
  • initialise and update variables correctly
  • use arithmetic operators in calculations
  • use logical and conditional operators to control decisions

If your variables and operators are poorly chosen, the rest of the program becomes harder to debug and harder to trust.