Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.

Similar presentations


Presentation on theme: "A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data."— Presentation transcript:

1 A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data type in terms of characteristics, memory requirements and purpose. COULD explain the difference data types and data structures giving examples Write simple programmes to manipulate simple data structures

2 A Level Computing#BristolMet Key Words

3 A Level Computing#BristolMet Data Types In programming it is very important to understand the type of data you are working with as the cpu handles each differently. This becomes apparent when working with variables. TASK: Use the hodder book pg 88 and create the table to include the specifics about the 4 variables in the keywords. PRACTICAL: Now try to run the basic add calculator in Python without assigning a variable type to the user input. What happens?

4 A Level Computing#BristolMet Declaring variables As we know, how an item of data is stored and manipulated in the computer depends on its data types. This is why it is important to define any items of data to be used in terms of its type. When an item of data is a variable, then defining the data type is called declaring the variable. Different languages do this in different ways, some you need to declare the variable at before the code and state: 1)An indentifier (name) for the variable 2)The data type of the variable Other languages, like Python, this is done at the line of execution (statement) which is called the assignment of a variable. REVISE: Compare the 2 calculator programmes, Python & Javascript

5 A Level Computing#BristolMet Data Structures Often we need to manipulate many different items of data and this would become cumbersome if we had to declare each item as individual variables. Therefore to simplify data can be grouped or structured and assigned a single identifier. The structures we will look at are: arrays and records. Arrays: 1 dimensional arrays are like a list, with each item in the list being ordered by a hidden index. TASK: Run the list_array program to see the number revealed. Now change the index to print the 2 nd number, then the last, and then first – what do you notice? TASK 2: Now change the elements of the list to include text like the colours above. What happens and why?? 0123 redyellowgreenblue Index Elements

6 A Level Computing#BristolMet Data Structures 1 dimensional arrays continued… The lowest and highest values of the index are called the bounds. In Python the lowest is set to 0 other languages are 1 and are declared along with the array elements. TASK 3: Use a FOR loop to print all of the items in the array. P. 90 of Hodder gives you the pseudocode 2 dimensional arrays are more like a table, with the columns having an index and the rows having a separate index. A bit like a spreadsheet 23112125 10771518 35102883 123123 1 2 3 4 The declaration of this array would be: DIM A (1 to 3, 1 to 4) : Integer

7 A Level Computing#BristolMet Data Structures To summarise, arrays are used for storing a series of similar data items together under 1 identifier. Sometimes we need to store several different items of data together, which where records are used: For example student records: RECORD Student Name : String Gender : Character Age: Integer END RECORD TASK: Create records for all students in the class and print one specific member. EXT: Adapt the programme to allow a user to query or search for one person and print all of the details.


Download ppt "A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data."

Similar presentations


Ads by Google