SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Data Types
Data Types
Computer programs need to process and store data
Programming languages define different data types to
store different types of data
We are interested in the following data types:
Integer, Real, String, Boolean, One-Dimensional Arrays
and Records
Integer
 An integer data type is used to store a whole number
 An integer can be positive or negative and includes 0
 e.g. 4, 1025, -27, 0, -911, 1
Real
 A real data type is used to store a decimal number
 A real can be positive or negative and includes 0
 e.g. 22.1, -13.775, 0.00, -5.15, 102.4258
String
 A string data type is used to represent alphanumeric
data (i.e. text)
 e.g. "Hello World", "0131 334 9262",
"How are you today?", "ABC-DEF-%£$-123"
 Most programming languages provide ways to
manipulate strings
e.g. get the string length, get the first character, get the
4th-6th characters, find the first space
Boolean
 A boolean data type can only represent 2 values: true
or false.
 Depending on the programming language true can also
be a 1 or yes, while false can be a 0 or no
One Dimensional Arrays
 An array is a series of objects all of which are the same type
 Each object in an array is called an array element
 The index of the first array element is normally zero
 Arrays are useful in programming because they can be used
with a loop
(eg count occurrences, linear search, find max/min)
One Dimensional Arrays
An example array of integers: The winning lottery balls
Uses:
Write a program to loop through checking a user’s
lottery numbers
One Dimensional Arrays
An example array of reals: Daily temperatures over a week
Uses:
Write a program to calculate the average daily
temperature in a week
One Dimensional Arrays
An example array of Strings: Pupil names
Uses:
Write a program to sort pupils into alphabetical order

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (12)

SD & D High and low level languages
SD & D High and low level languagesSD & D High and low level languages
SD & D High and low level languages
 
ISDD Database Structure N5
ISDD Database Structure N5ISDD Database Structure N5
ISDD Database Structure N5
 
ISDD User Interface
ISDD User InterfaceISDD User Interface
ISDD User Interface
 
N5 Computing Science - Readability of code
N5 Computing Science - Readability of codeN5 Computing Science - Readability of code
N5 Computing Science - Readability of code
 
SD & D variables and assignment
SD & D variables and assignmentSD & D variables and assignment
SD & D variables and assignment
 
N5 ISDD Testing
N5 ISDD TestingN5 ISDD Testing
N5 ISDD Testing
 
N5 ISDD Hardware Requirements
N5 ISDD Hardware RequirementsN5 ISDD Hardware Requirements
N5 ISDD Hardware Requirements
 
National 5 Computing Science - Testing
National 5 Computing Science - TestingNational 5 Computing Science - Testing
National 5 Computing Science - Testing
 
ISDD Networking & Connectivity
ISDD Networking & ConnectivityISDD Networking & Connectivity
ISDD Networking & Connectivity
 
Database Validation
Database ValidationDatabase Validation
Database Validation
 
Higher Computing Science HTML
Higher Computing Science HTMLHigher Computing Science HTML
Higher Computing Science HTML
 
ISDD Standard File Formats
ISDD Standard File FormatsISDD Standard File Formats
ISDD Standard File Formats
 

Ähnlich wie National 5 Data Types

Ähnlich wie National 5 Data Types (20)

Data types
Data typesData types
Data types
 
Python for Everybody - Solution Challenge 2021
Python for Everybody - Solution Challenge 2021Python for Everybody - Solution Challenge 2021
Python for Everybody - Solution Challenge 2021
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Arrays
ArraysArrays
Arrays
 
Arrays
ArraysArrays
Arrays
 
Software fundamentals
Software fundamentalsSoftware fundamentals
Software fundamentals
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
 
PPt. on An _Array in C
PPt. on An _Array in CPPt. on An _Array in C
PPt. on An _Array in C
 
Array in c
Array in cArray in c
Array in c
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Arrays declartion and initialization
Arrays declartion and initializationArrays declartion and initialization
Arrays declartion and initialization
 
Arrays in C
Arrays in CArrays in C
Arrays in C
 
The Ring programming language version 1.6 book - Part 182 of 189
The Ring programming language version 1.6 book - Part 182 of 189The Ring programming language version 1.6 book - Part 182 of 189
The Ring programming language version 1.6 book - Part 182 of 189
 
CIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and VariablesCIS 1403 Lab 2- Data Types and Variables
CIS 1403 Lab 2- Data Types and Variables
 
Arrays in c++
Arrays in c++Arrays in c++
Arrays in c++
 
Data Science Using Scikit-Learn
Data Science Using Scikit-LearnData Science Using Scikit-Learn
Data Science Using Scikit-Learn
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
Week 11.pptx
Week 11.pptxWeek 11.pptx
Week 11.pptx
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 

Mehr von Forrester High School

Mehr von Forrester High School (20)

Program Design
Program DesignProgram Design
Program Design
 
Database Evaluation
Database EvaluationDatabase Evaluation
Database Evaluation
 
Testing SQL
Testing SQLTesting SQL
Testing SQL
 
SQL
SQLSQL
SQL
 
Database Query Design
Database Query DesignDatabase Query Design
Database Query Design
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Compound Keys
Compound KeysCompound Keys
Compound Keys
 
Entity Occurrence Diagrams
Entity Occurrence DiagramsEntity Occurrence Diagrams
Entity Occurrence Diagrams
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
Database Analysis
Database AnalysisDatabase Analysis
Database Analysis
 
Software Evaluation
Software EvaluationSoftware Evaluation
Software Evaluation
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Standard Algorithms
Standard AlgorithmsStandard Algorithms
Standard Algorithms
 
File Handling
File HandlingFile Handling
File Handling
 
Python Predefined Functions
Python Predefined FunctionsPython Predefined Functions
Python Predefined Functions
 
Python Substrings
Python SubstringsPython Substrings
Python Substrings
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Sub-programs
Sub-programsSub-programs
Sub-programs
 
Records in Python
Records in PythonRecords in Python
Records in Python
 
Parallel arrays in python
Parallel arrays in pythonParallel arrays in python
Parallel arrays in python
 

Kürzlich hochgeladen

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Kürzlich hochgeladen (20)

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

National 5 Data Types

  • 2. Data Types Computer programs need to process and store data Programming languages define different data types to store different types of data We are interested in the following data types: Integer, Real, String, Boolean, One-Dimensional Arrays and Records
  • 3. Integer  An integer data type is used to store a whole number  An integer can be positive or negative and includes 0  e.g. 4, 1025, -27, 0, -911, 1
  • 4. Real  A real data type is used to store a decimal number  A real can be positive or negative and includes 0  e.g. 22.1, -13.775, 0.00, -5.15, 102.4258
  • 5. String  A string data type is used to represent alphanumeric data (i.e. text)  e.g. "Hello World", "0131 334 9262", "How are you today?", "ABC-DEF-%£$-123"  Most programming languages provide ways to manipulate strings e.g. get the string length, get the first character, get the 4th-6th characters, find the first space
  • 6. Boolean  A boolean data type can only represent 2 values: true or false.  Depending on the programming language true can also be a 1 or yes, while false can be a 0 or no
  • 7. One Dimensional Arrays  An array is a series of objects all of which are the same type  Each object in an array is called an array element  The index of the first array element is normally zero  Arrays are useful in programming because they can be used with a loop (eg count occurrences, linear search, find max/min)
  • 8. One Dimensional Arrays An example array of integers: The winning lottery balls Uses: Write a program to loop through checking a user’s lottery numbers
  • 9. One Dimensional Arrays An example array of reals: Daily temperatures over a week Uses: Write a program to calculate the average daily temperature in a week
  • 10. One Dimensional Arrays An example array of Strings: Pupil names Uses: Write a program to sort pupils into alphabetical order