Computer Science

Senior High

NotesFree

Data Types and Data Structures: Why Organising Data Matters

Topic: Y1 Data structures and their importance

What data types, variables and data structures are and why they matter, explained step by step: data types and variables in Python, why we use data structures, linear and non-linear, static and dynamic; data types including characters and pointers, and sequential, tree-based and graph-based structures.

View resource Free to join

What's inside

Imagine a school library where thousands of books are thrown into one big heap. Finding a single Geography textbook could take all day. Now picture the same books arranged by subject, each shelf labelled, each book numbered. Finding one takes seconds. The books are the same; what changed is how they are organised. Computers face this problem with data all the time, and the answer is the data structure.

summarized notes

  • Year 1: Data types and variables, what data structures are and why they are important, and how they are classified (linear and non-linear; static and dynamic), plus common operations.

  • Year 2: Data types including characters and pointers, what a data structure is, and the three groups: sequential, tree-based and graph-based.

Year 1: Data types, variables and why data structures matter

Data types

Your age is a whole number, your height has a decimal point, your name is a string of letters, and "Are you present?" is a yes-or-no answer. These are different kinds of data, and a computer must know which kind it is dealing with, so it knows what it can do with it (you can add two ages, but not two names in the same way).

The textbook defines a data type as an attribute of a piece of data that tells the computer how to interpret its value. A single value, such as the name "Abena", is called a data item. Common data types, built into most programming languages, are:

Data type

Python name

Holds

Example

Integer

int

Whole numbers

1961

Floating-point

float

Numbers with a decimal point

43.5

String

str

Text: a sequence of characters

"Hello World"

Boolean

bool

True or False

True

Variables

A variable is a named location in memory that stores a value, like a labelled box. Its data type decides which operations can safely be done with it. Names can be short (x, y) or descriptive (age, carName, total_volume). In Python, a variable name must start with a letter or underscore, cannot start with a number, may contain only letters, digits and underscores, and is case-sensitive (age, Age and AGE are three different variables).

Python sets a variable's type when you give it a value: x = 1961 makes an int and x = "Hello World" makes a str. You can convert between types: int(43.5) gives 43 (the decimal part is cut off), and str(1961) gives the text "1961". The type() function tells you a value's type. Be careful: if x = "4" and y = "5" are strings, then x + y gives "45", joining the text instead of adding the numbers.

Open the full resource free with a TudHub account.

More on Data structures and their importance

Other resources you can find on TudHub.

Data Types and Data Structures: Why Organising Data Matters (Computer Science) · TudHub