Download presentation
Presentation is loading. Please wait.
1
Data Types and Structures
Component 1.4 Data Types and Structures
2
Starter: Pre-Reading Recap
What is Data? What data type would a phone number be? Why? What are the four main data types? What does a Data Structure mean? Give an example of some data that would be a string Give two types of data structure Give an example of some data that would be a Boolean Explain what an Array is Explain what a record is What is the difference between an integer and a float (real) What can a record hold that an Array can’t?
3
Learning Intentions and Outcomes
Grade 4 Describe the concept of data types, including integer, Boolean, real, character and string Describe, design, interpret and manipulate data structures including records, one-dimensional and two-dimensional arrays Grade 5 Design files and records appropriate for a particular application Explain and use appropriate techniques for data validation and verification Grade 6 Use and explain appropriate data types to design files and records appropriate for a particular application Grade 7 Evaluate a collection of data to determine appropriateness of data types and structures
4
Learning Outcome Sheet
Fill in your learning outcome RAG sheet, stick this in underneath your title. Grade 4 Describe the concept of data types, including integer, Boolean, real, character and string Describe, design, interpret and manipulate data structures including records, one- dimensional and two-dimensional arrays Grade 5 Design files and records appropriate for a particular application Explain and use appropriate techniques for data validation and verification Grade 6 Use and explain appropriate data types to design files and records appropriate for a particular application Grade 7 Evaluate a collection of data to determine appropriateness of data types and structures
5
What is Data? Data is words, numbers, dates, images, sounds etc. without context When we apply context (knowledge) through processing the data we get information
6
Data Types Data type Description Examples
Integer Whole numbers, positive or negative 42, -11, 0 Real Numbers, including fractions or decimal points 12.9, , 28.0 Boolean True or false 1 or 0 Character Letter, digit, space, punctuation mark or various other symbols 'A', 'b', '7','?' String A sequence of characters ‘Computer science’ ‘The cat sat on the mat’
7
Strings and Characters
The String or Character data type can hold any letter, number, symbol or punctuation mark. It is sometimes referred to as 'alphanumeric' or 'string'. The data can be pure text or a combination of text, numbers and symbols. In python we make a variable a string by putting str() around it: Name = str(“Alex”) Examples of text data types in use:
8
Integers Integers are whole numbers represented as binary values. Most programming languages provide a data type called 'integer', often called 'int' for short. In python we make a variable an integer by putting int() around it: Age = int(15)
9
Real (Floats) Floating point numbers are numbers that have a fractional part, usually represented using two components: the main number and the fractional part, each of which is a binary number. This is known as a floating-point representation. Most programming languages provide one or more data types based on floating-point representations. They are usually given names like 'float', 'single', 'double', 'real' or 'longreal'. In python we make a variable a float by putting float() around it: Pi = float(3.14)
10
Booleans Boolean data holds one of two allowable values, for example:
Yes or No True or False A Boolean data type is used to answer questions that have exactly two responses. If a third response were present it is not Boolean data Examples of Boolean data questions: Are you over 15? Do you have a job? Do you have blue eyes?
11
Grade 4 – Data types Complete the first question of the graded exercises. Extension: Explain how a variable can have each data type cast over it in python: Boolean Float String Integer Data Type Contains Example Variable Name Example Data String / Character Integer Float (Real) Boolean A Boolean data type is used to answer questions that have exactly two responses. If a third response were present it is not Boolean data. Over18 True / False
12
Data Structures A data structure is a specific way of organising data within memory so that it can be processed efficiently. There will be a relationship between the data items that will vary according to the type of data structure being used. Exactly what the relationships are determine what type of data structure is being used. Typical operations on a data structure are: ADD INSERT DELETE or REMOVE FIRST NEXT LAST LOCATE
13
Static and Dynamic Data Structures
A static data structure is designed to store a known number of data items. The values of the data can be changed but the memory size is fixed As static data structures store a fixed number of data items they are easier to program, as there is no need to check on the size of the data structure or the number of items stored. For example a high scores board on a video game may record the last 10 high scores. If a new one is entered the last one is lost! Dynamic data structures are designed to allow the data structure to grow or shrink at runtime. It is possible to add new elements or remove existing elements without having to consider memory space. Dynamic data structures make the most efficient use of memory but are more difficult to program, as you have to check the size of the data structure and the location of the data items each time you use the data. For example a shopping list may have different amounts of items on it each week. A program to make a shopping list will need to be dynamic and let the number of entries change!
14
Static and Dynamic Data Structures
15
Lists A list is a data structure that has the data items stored in the order they were originally added to memory. If the list is made up of a set number of data items, then it can be a static data structure. If the list can vary in the number of data items, then it will be a dynamic data structure.
16
Arrays An array is a data structure that can hold a fixed number of data items, which must be of the same data type i.e. real, integer, string etc. The data items in an array are known as elements. An array is an example of a static data structure; we can change the values of the elements in the array but we cannot alter the memory size allocated to the array. The elements in an array are identified by a number that indicates their position in the array. This number is known as the index. The first element in an array usually has an index of 0. 42 56 6 26 4 76 37 11 Elements Index
17
arrays There are 8 elements in this array.
The index always starts at position 0. Each element can be accessed using its index. The element at index 5 is 56. This type of array is known as a one-dimensional array.
18
One Dimensional Arrays
A one dimensional array has one index – it stores an element in one position. The element is referenced by calling the Array name and the location: ArrTopScore = [50, 45, 44, 43, 40] ThirdPlace = ArrTopScore[2]
19
Two-Dimensional Arrays
Often the data we want to process comes in the form of a table. The data in a two-dimensional array must all be of the same data type. For example a spreadsheet that contains all of the marks for your test this year.. Elements in a two-dimensional array are indexed by two numbers – one for the row it is in and one for the column. If the two-dimensional array is called testMark then the command to declare this array would be: testMark [4,5] In this declaration, the 4 refers to the number of pupils (rows) and the 5 to the number of tests (columns). The index for Sam’s marks for Test 2 would be [0,1].
20
Grade 4 – Data Structures and Arrays
Complete questions 1-11 of the Data Structures and Arrays questions Extension Explain the difference between a one and two dimensional array, providing examples of when each array would be used.
21
Records Arrays can only hold data if it is all of the same data type.
If you need to hold related data of different data types you will need to use a data structure called a record. A record will be made up of information about one person or thing. Each piece of information in the record is called a field. For example, an after school club wants to store data about its members’ emergency contact information. Field Name Field Type Example data Membership Number Integer 1074 First name String Sara Surname Davies Date of Birth Date 12/07/2004 Contact Name Mrs Davies Contact phone number
22
Records: Key Fields Each record in a file should have a key field. That is an item of data that is unique and can be used to identify the individual record. In this example the membership number would be the key field.
23
Files For a computer to function it must have data flowing through the central processing unit (CPU) under the control of a program. More often than not this data will have come from a stored file. A program will load the file from secondary storage, such as a hard disc, into the computer’s memory. The data will be manipulated by the CPU and then output. The output could be another data file, screen images or a document. Data stored in a file will have a structure and organisation known as the file format. A data file will be made up of records. It would be most efficient for the fields in a record to be stored next to each other so that the data can be read into the record data structure in memory for processing by the CPU. In summary – files are made of records of the same structure and records are made up of fields containing information about one person or item.
24
Grade 4 – Records and Files
Complete questions 1-4 of the Records and Files questions Extension Find out what a foreign key is and explain how it is related to records. You will need to complete independent research for this. A good website is
25
Validation Validation is a process to check that input data is reasonable or sensible. Frequently used validation algorithms include; For example you might ask someone to input their date of birth. My date of birth is 25/03/1991.. But I could enter 07/05/1989 if I wanted to. Both sets of data are valid because they are both sensible – however Presence checks Used to prevent further progress if a required field is left blank. Format checks Used to ensure data matches a specific pattern, such as dd/mm/yyyy for a date. Input masks are often used to create format checks on database forms. Length checks Used to ensure an input data string is a sensible length e.g. number of characters in ‘firstName’ to be between 3 and 16 Type checks Used to ensure input data is a particular data type e.g. quantity ordered to be integer or cost to be real. Range checks Used to ensure input data lies within a specified range e.g. over time hours to be > 0 and < 15.
26
Verification Surname String National Insurance (NI) number Standard format LL123456L Job title Apprentice, semi-skilled, skilled, supervisor Week no. Integer Full time Y or N, Full time = 38 hours per week Hours worked Integer, hours worked in current week, maximum 10 hours overtime in one week. Overtime rate = 1.5 x pay rate Pay rate Real, hourly pay rate, max £ / hour Verification is a process for checking data is correct. It can be carried out as a user enters data, such as via a keyboard and also when data is copied from one part of a system to another. Copying should not change the data. Examples of verification of user input include double entry and screen based verification. Double entry involves comparing two versions of data input. e.g.” re- enter your address”. A verification algorithm will compare the two versions and inform the user if they are not identical.
27
Grade 4 – Validation and Verification
Complete questions 1-5 of the Validation and Verification exam questions Extension Move on to the Exam Questions at the front of the room.
28
Graded Exam Questions Exercises
Complete Grade 5-7 Graded Exercises When you have completed these self-assess them using the mark schemes provided Extension Move on to the Grade 8 Extension Remember to be smart when using the Internet: Wikipedia is often complicated – sometimes even I don’t understand! BBC Bitesize, Teach ICT, and Revision World are better places to find your information!
29
Crib Sheet – What I must remember about ___
Starting Point: Read the learning outcomes from the exam board Record the key facts that you need to remember about Data Types and Data Structures! Think about what you have learnt today, what questions you have been asked, definitions of words, or anything else you think is important!
30
Homework Graded Exercises Complete up to your year 11 target grade
Question Sheets Q51 – Data Types Revision At least 2 pages of revision resources. For example: Cue Cards Mind Maps Notes Posters
31
Traversing an Array Traversing an array simply means using a loop to use each element of the array in a section of a program. If you wanted to print out the contents of an array called myArray that has 10 elements you would use a ‘for next’ loop. Like this:
32
Inserting into and deleting from an array
You can add an element to an array at a given index. myArray[3] = 27 This would store the value 27 at the index 3 of the array You can delete an element from an array. myArray[6] = “” This would leave the memory at index 6 blank. Search Arrays can be search using the index or the value stored at the index.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.