0% found this document useful (0 votes)
4 views

Year 10 Data Type and Data Structure

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Year 10 Data Type and Data Structure

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 30

OMEGA TERM SCHEME

Year 10

1. Data Types
2. Variables and constants
3. Input and Outputs in programming
4. Sequence
5. Totaling
6. counting
7. Selection
8. Iteration
9. Solving problems
10. Revision
DATA TYPES AND
STRUCTURES
DATA TYPES OBJECTIVES

• Knowledge objective: Explain the concept of data type


• Learning Objective: Give examples of datatypes,
• Learning Objective: declare string, float, Boolean datatypes
• Skill objective: solve IGCSE question on data types

DATA TYPES
• A data type is a formal classification of the type of data being
stored or manipulated within a program.

• Data types are important because they determine the operations


that can be performed on the data. For example, you can divide
one number by another, but you can't divide a word by another
word.
VARIOUS DATA TYPES
Data type Description Example
Integer An integer is a whole number. The -5, 123, 0
numbers can positive or negative but
they must be whole. This means that
they do not have any decimal places.
Real Real is also referred to as float. Real 1.1, -1.0,
(float) numbers include numbers with decimal 382.0, 12.125
places. A real number can be positive or
negative.
Boolean The Boolean data type is based on logic True, False
and can have one of only two values,
True or False.
COMMON DATA TYPE
Char Char refers to a single character. The character c, A, X, £
can be any letter, digit, or symbol.

String The string data type refers to text. A string is a Hello, 1$34A,
collection of characters and includes spaces, ninety-four
punctuation, numeric digits and any other
symbols such as $, &, £, etc. Strings can also
contain numeric digits but these will be
handled as text characters, not numbers.

Null A null value is used to indicate ‘nothing’; the Null


lack of any value, of any type of data.
pical memory allocated to each of the common data types.

MEMORY REQUIREMENT

Data type Memory allocation

Character 4 bytes (Unicode)

String 4 bytes for each character (Unicode)

Boolean 1 bit

Integer 4 bytes

Float 4 bytes
DATA STRUCTURES
Objectives - To:
• Knowledge objective: Explain the concept of data structure
• Learning Objective: explain the functions of data structure in
programming,
• Attitude objective: describe the various types of data structures
(constant, variable and array)
• Skill objective: Write simple code using these data structures
• Success criteria: The students need the following to be successful in
this lesson:
Understand what pseudocode is.
• Keyword: problem solving, pseudocode
What is a Data Structure?
 Defined in a program to store single or multiple pieces of
data, it allows you to group related data together.

 Data Structures mean that a program is more efficient. As


data can be accessed and managed within one location.

 Think of data structure as a container(bucket) while the data


itself is the content.
Variables 
 A variable is used to store Variables can change during
single values of a specific the course of a program
type. They can be empty or
with a value at initiation. total --> milk + eggs
total --> total + transport
total --> total + VAT
OUTPUT total
Initializing a variable

• Initialize means to assign a value to a variable at the initial stage of declaration e.g

•SET Name --> “Ola”


• PriceOfBook --> 20
• Final_Price --> 0
• Gender --> “M”
• Score --> 45.6
Declaration of variable
•Declare Name AS STRING
•Declare PriceOfBook AS int
•Declare Final_Price AS float
•Declare Gender AS CHAR
•Declare Score AS FLOAT
Variables
  String variables always
Variables can be strings
or numeric have a speech mark
around them and cannot
be used for calculations
Name --> “Ola”
PriceOfBook --> 20
Final_Price -->25:60
Classwork 1

Create a variable and Store your first name

Use the print or output statement to print


out your variable
Constants
  constants cannot change
A constant is used to store single
values of a specific type. They during the course of a
can be empty or with a value at program
initiation.

CONST pi = 3.141 AS
Float
CONST VAT = 7.5
Difference between variable and constant

 Variables can change during the course of a program while Constant does not


--> milk + eggs
Example of Variable changing in the course of a program
total

total --> total + transport

total --> total + VAT


OUTPUT total
Classwork 2

Consider the extract below and identify any variable or constant that will be needed for this program.
e.g item_number will be a variable
ARRAYS
Objectives:
• List out the different array data structures
• Differentiate between the different types of arrays
• Create 1-dimensional arrays

• Success criteria: The students need the following to be successful in


this lesson:
Understand what pseudocode is.
• Keyword: problem solving, pseudocode
Arrays
 Used to store lists of data with the same data
type. Defining an array involves stating its name
and size. An array uses up less data than using
multiple variables to store the same amount of
data.

 There are two types of arrays:


› 1 Dimensional
› 2 Dimensional
1 Dimensional Arrays
 Data is stored in a single row.
 Each piece of data is given a position within the
array. (an index)
 The first piece of data in an array is given the position 0
eg. DECLARE carMakers[0:5] AS STRING //string array for 6 values
DECLARE Ages_of_Year_10 [] AS INTEGER //Empty integer array

0 1 2 3 4
CarMakers[3] //This will bring out Nissan
Questions
1. In terms of an array, what is an index?

A value which points to a data element


in an array

The first element in an array

A list of all the elements in an array


Questions

In the array marks(9, 10, 8, 5, 9) what is the


element with the index (3)?

5
Questions

What is meant by 'declaring' an array?

Creating an array in a program,


specifying its name and size

Giving an array in a program,


specifying its size

Placing initial values into an array


Questions

Which of the following is not a valid array?

names=["Tom","Ali","22","Connie”]

scores=[2,3,5,4,2,1]

names=("Tom", "Ali", 22, "Connie")


I/O

INPUT variable_name PRINT variable_name


Assignment

• Consider an array to store 10 prices of toys


• a Is the first element 1 or 0?
• b How do you declare the size of an array?
• c Can you declare the type of the array?
• d Declare an array to store the test marks for a
class
• of 30 students.

You might also like