2d Arrays.

Slides:



Advertisements
Similar presentations
Two-Dimensional Arrays Chapter What is a two-dimensional array? A two-dimensional array has “rows” and “columns,” and can be thought of as a series.
Advertisements

A spreadsheet is like a big table. It contains rows and columns which work together. Left-click to go to the next slide.
11-1 Chapter 11 2D Arrays Asserting Java Rick Mercer.
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
Designing a Database Unleashing the Power of Relational Database Design.
One Dimensional Arrays. Declaring references to array objects How would you declare a variable somearray that is an array of ints? int[] somearray;
Lists in Python.
 2005 Pearson Education, Inc. All rights reserved. 1 Arrays.
Enhanced For Loops (For Each Loops) Less Code and Less Overhead for Writing For Loops.
Excel Spreadsheet Notes. What is a Spreadsheet? Columns and rows of data.
Computing Science 1P Large Group Tutorial 13 Simon Gay Department of Computing Science University of Glasgow 2006/07.
CSD 340 (Blum)1 For Loops See Beginning JavaScript (Paul Wilton) p. 87.
Topic: Code Essential Questions Digital Cornell Notes.
Visual C# 2005 Using Arrays. Visual C# Objectives Declare an array and assign values to array elements Initialize an array Use subscripts to access.
Table of Contents Matrices - Definition and Notation A matrix is a rectangular array of numbers. Consider the following matrix: Matrix B has 3 rows and.
Arrays and variables 1.Representing tables as arrays in MATLAB 2.Concept of array dimension 3.Correspondence of array dimension to rows and columns 4.Picking.
What does this say? Matrix Multiplication ! What does this say?
ARRAY AND LOOPS REVIEW Mr. Crone. What will the code below print? int[] arry = {2, 5, 2, 1, 3}; for(int i = 0; i < 5; i ++) System.out.print(arry[i]);
Database (Microsoft Access). Database A database is an organized collection of related data about a specific topic or purpose. Examples of databases include:
Periodic Table  Organized like a big grid  Has rows (left to right horizontally) called periods  Has columns (top to bottom vertically) called groups.
Trace Tables In today’s lesson we will look at:
MoversSuite Administration
Chapter 6: Using Arrays.
Lecture 5 of Computer Science II
Sections 2.4 and 2.5 Matrix Operations
12-1 Organizing Data Using Matrices
Arrays.
Two-Dimensional Arrays
1.5 Matricies.
Two-dimensional arrays
Two Dimensional Array Mr. Jacobs.
Two-Dimension Arrays Computer Programming 2.
Interfacing with a database
Dynamic Array Multidimensional Array Matric Operation with Array
EGR 115 Introduction to Computing for Engineers
Matrix Operations.
Sit-In Lab 1 Ob-CHESS-ion
JavaScript: Functions.
Two-Dimensional Arrays
How to Create Tables & Charts/Graphs in Excel
1-Dimensional Arrays 2-Dimensional Arrays => Read section 1.4
Arrays An Array is an ordered collection of variables
7.3 Matrices.
Python I/O.
Multidimensional Arrays Vectors of Vectors
Manipulating Arrays.
4.5 Determinants of Matrices
4-1 Organizing Data Into Matrices
Matrices Elements, Adding and Subtracting
Data Structures – 2D Lists
First we need to draw a place table grid. Then write our number in it
Section 2.4 Matrices.
Data Tables and Arrays.
MSIS 655 Advanced Business Applications Programming
Sorting "There's nothing in your head the sorting hat can't see. So try me on and I will tell you where you ought to be." -The Sorting Hat, Harry Potter.
Multidimensional array
Lets Play with arrays Singh Tripty
15-110: Principles of Computing
3.5 Perform Basic Matrix Operations
Print the following triangle, using nested loops
Introduction to Computer Science
Chapter 4 Matrices & Determinants
EECS Introduction to Computing for the Physical Sciences
Insertion Sort.
Working with Arrays in MATLAB
Arrays and Matrices Prof. Abdul Hameed.
Databases WOW!! A database is a collection of related data.
Arrays.
Announcements.
Tuple.
Presentation transcript:

2d Arrays

2D Arrays: the list can be thought of as being stored in a table in columns and rows - a matrix Pos 1 2 3 4 5 6 7 8 9 The left hand column refers to each sub list, start from 0, the top row is the postion number. For example what number is at List 1 position 1? = 5

2D Array (Lists within a list) Print as a tabbed grid print (list) To print as a table use: for i in list: print (i) The array called list is made up of three separate lists ITERATION “I” means integer

Print individual data from a specific list or column students = [["dave", 14, "11DA"], ["liz", 18, "7ED"], ["kerry", 7, "8MD2"]] print (students) print(students[0][2]) print(students[2][2]) Print(students[1][3]) (the first number say [0] is the list number and the second number [2] is the position of the data to be printed, list 0, position 2, = 11DA) You have to refer to the list number ad the position of the item in that list What do the three examples print? Prints 11DA Prints 8MD2 Nothing – error there is no third item.

Print one data element from a specific column in each list, (print one column) students = [["dave", 14, "11DA"], ["liz", 18, "7ED"], ["kerry", 7, "8MD2"]] print (students) Print just the ages: for i in students: print(i[1]) (where i is each of the individual lists and [1] refers to the position one in each list, the age, alter the code to print the tutor group) To print all the data from one column, select the arry name and use a loop to iterate through

Print one data element from a specific column in each list, (print one column) students = [["dave", 14, "11DA"], ["liz", 18, "7ED"], ["kerry", 7, "8MD2"]] Task Print items just in the names column: for i in students: print(i[???]) Another Example

Another method to print columns list = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]] print (list) for x in range(0, 3): print(list[x][0]) X is the row so it states for each row from 0 to 2, as there are three rows, print the item at position 0, the first entries.

Print the third column using x axis list = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]] print (list) for x in range(0, 3): print(list[x][2]) X is the row so it states for each row from 0 to 2, as there are three rows, print the item at position 2 the third item in each of the lists Remember position starts from 0, item number is from 1

Print the third column – using y axis list = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]] print (list) for y in range(0, 3): print(list[y][2]) y is the column so it states for each column from 0 to 2, as there are three columns, print the item at position 2, the third entry.