Primitive Data Types (SQA National 5 Computing Science): Revision Note

Exam code: X816 75

Robert Hampton

Written by: Robert Hampton

Reviewed by: James Woodhouse

Updated on

Primitive data types

What is a data type?

  • A data type is a classification of data into groups according to the kind of data they represent

  • Computers use different data types to represent different types of data in a program

  • The basic data types include:

Data type

Used for

Pseudocode

Example

Integer

Whole numbers

INTEGER

10, -5, 0

Real

Numbers with a fractional part (decimal)

REAL

3.14, -2.5, 0.0

Character 

Single character

CHAR

'a', 'B', '6', '£'

String

Sequence of characters

STRING

"Hello world", "ABC", "@#!%"

Boolean

True or false values

BOOLEAN

True, False

  • It is important to choose the correct data type for a given situation to ensure accuracy and efficiency in the program

  • Data types can be changed within a program, this is called casting

Programming data types

Data type

Pseudocode (SQA style)

Python

Integer

SET number TO 5

number = 5

Real

SET realNumber TO 3.14

realNumber = 3.14

Character

SET firstInitial TO 'A'

firstInitial = 'A'

String

SET password TO "letmein"

password = "letmein"

Boolean

SET lightSensor TO True

lightSensor = True

Worked Example

A sports shop requires a program to store information about football boots.

Complete the table below to state which types of variable should be used.

[3]

Variable

Type of variable

bootBrand

availableInStore

bootSize

Answer

Variable

Type of variable

bootBrand

String [1 mark]

availableInStore

Boolean [1 mark]

bootSize

Integer [1 mark]

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Robert Hampton

Author: Robert Hampton

Expertise: Computer Science Content Creator

Rob has over 16 years' experience teaching Computer Science and ICT at KS3 & GCSE levels. Rob has demonstrated strong leadership as Head of Department since 2012 and previously supported teacher development as a Specialist Leader of Education, empowering departments to excel in Computer Science. Beyond his tech expertise, Robert embraces the virtual world as an avid gamer, conquering digital battlefields when he's not coding.

James Woodhouse

Reviewer: James Woodhouse

Expertise: Computer Science & English Subject Lead

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.