

Arrays
Presentation
•
Computers
•
11th Grade
•
Practice Problem
•
Medium
K Parker
Used 51+ times
FREE Resource
11 Slides • 19 Questions
1
Arrays
So far we have only used variables to store 1 value, eg:
name = "Bob"
An array allows us to store multiple values in 1 variable. It is like a LIST. eg:
name = ["bob", "Sally", "Harry"]

2
Open Ended
What is an array?
3
What is an array?
Array is a container which can hold a fix number of items and these items should be of the same type. For example, here is an array called Fruit. It contains 4 items of fruit
Fruit = ["Apples", "Plums", "Oranges", "Grapes"]
Notice the SQUARE brackets. This is so that Python knows that it is an ARRAY.
Notice that all items (fruits)in my array are of the same type of DATA (string) and I have separated each item with a comma (,)
4
Fill in the Blanks
Type answer...
5
Fill in the Blanks
6
Open Ended
Create your own array
Has to include at least 2 items
Can be anything you want - football teams, colours, TV shows etc
7
Finding an item within an ARRAY
Here is my fruit array:
Fruit = ["Apples", "Plums", "Oranges", "Grapes"]
When we could the items in an array we ALWAYS start at 0 So, in my array above "Apples" is item number 0, Plums is item number 1 and so on
8
Fill in the Blanks
Type answer...
9
Fill in the Blanks
Type answer...
10
Fruit = ["Apples", "Plums", "Oranges", "Grapes"]
If I wanted to print the third item in my array ("Oranges") to the screen I would type this:
print (Fruit [2])
Notice that I have asked to print the array called Fruit and I have asked for only the item number 2 – this is in SQUARE brackets []
11
Fill in the Blanks
Type answer...
12
Fill in the Blanks
Type answer...
13
Fill in the Blanks
Type answer...
14
Arrays and SELECTION
Here in an array that holds items (data) about 1 car:
Car = ["Vauxhall", "Astra", "TRUE"]
The third item refers to if the car has a valid MOT certificate
We can start to use SELECTION to ask our array a question
In this case I want to check if the car has a valid MOT certificate, if it has then I do NOT want to call the owner, if it doesn't have a valid certificate then I DO want to call the owner
15
Car = ["Vauxhall", "Astra", "TRUE"]
If Car [2] == "TRUE":
print ("Do not call owner")
else:
print("Call owner")
16
Fill in the Blanks
17
Fill in the Blanks
18
Fill in the Blanks
19
Multiple Choice
Arrays hold multiple values of different types.
True
False
20
Multiple Choice
What best describes an array in programming?
An array is a single element data type that can be changed in the porgram.
An array is a type of function in programming that can be re-used repeatedly
A data structure that holds multiple values stored in an index.
An array is a method for sorting data to make it more effic
21
1-Dimensional Array
This is a single list of data. Each piece of data is stored a index, we then refer to the index to edit, replace or remove the data.
Creating an array works similarly to a variable, however we use square brackets:
StudentNames = ["Lucy" , "Andrew" , "Libby" , "Mark"]
We can then refer to each index location, rather than the data stored in the array.
If this was a variable it would need 4 separate names e.g.
student1 = "Lucy"
student2 = "Andrew"
22
1-Dimensional Array
We can use the following code to manipulate the data in the same array.
StudentNames [2] would return Libby
StudentNames[1] = "Adam" would replace Andrew with Adam
StudentNames[4] = "Greg" would add a new index storing Greg
Print[StudentNames] would print all data in each index.
23
Multiple Choice
What would the correct code to make the following array, read each one carefully:
StudentNames = ("Lucy" , "Andrew" , "Libby" , "Mark")
StudentNames = ["Lucy" "Andrew" "Libby" "Mark"]
StudentNames = [Lucy , Andrew , Libby , Mark]
StudentNames = ["Lucy" , "Andrew" , "Libby" , "Mark"]
24
Open Ended
Design pseudocode to create an array name colours, the array will store 4 colours: white, pink, red and blue in that order:
25
A 2D Array is a list that stores multiple values with multiple rows.
This data structure stores data in a table. Each index is given two numbers, one for the row and the other for the column.
In the exam it will tell you whether you refer to row or column first, or it will give you an example like this.
2D Arrays
26
Manipulating 2D Arrays
To make a 2D array, is quite similar, the only difference is you will need multiple pairs of square brackets. Each new pair will be a new row:
ClassCodes = [["Y7A","Y7B","Y7C"],["Y8A","Y8B","Y8C"],["Y9A","Y9B","Y9C"]]
If we were to visualise the 2D array this is what it would look like as a table:
27
Manipulating 2D Arrays
When referencing an index location in our array, we use 2 numbers. In this situation we will refer to row first and column second, if only one index location is given it will output the results from the entire row or column e.g.
ClassCodes [2] would output all Y9
ClassCodes [1,2] would output Y8C
ClassCodes [0,1] would output Y7B
28
Multiple Choice
How is a 2D array different from a 1D array?
A 2D array has rows and columns, whereas a 1D array has only a single row
29
Fill in the Blanks
30
Fill in the Blanks
Arrays
So far we have only used variables to store 1 value, eg:
name = "Bob"
An array allows us to store multiple values in 1 variable. It is like a LIST. eg:
name = ["bob", "Sally", "Harry"]

Show answer
Auto Play
Slide 1 / 30
SLIDE
Similar Resources on Wayground
22 questions
ACT Practice Reading
Presentation
•
11th Grade
25 questions
Physical and Chemical Changes Review
Presentation
•
8th Grade
24 questions
Government Response to the Great Depression
Presentation
•
11th Grade
23 questions
Wave Mechanics
Presentation
•
11th Grade
23 questions
Waves Review
Presentation
•
11th Grade
24 questions
Spanish present perfect tense
Presentation
•
11th Grade
22 questions
Atoms, Isotopes, and Ions
Presentation
•
11th Grade
22 questions
Free Body Diagrams
Presentation
•
11th Grade
Popular Resources on Wayground
20 questions
STAAR Review Quiz #3
Quiz
•
8th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
6 questions
Marshmallow Farm Quiz
Quiz
•
2nd - 5th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
19 questions
Classifying Quadrilaterals
Quiz
•
3rd Grade
12 questions
What makes Nebraska's government unique?
Quiz
•
4th - 5th Grade
Discover more resources for Computers
20 questions
Grammar
Quiz
•
9th - 12th Grade
31 questions
Easter Trivia
Quiz
•
KG - 12th Grade
16 questions
Circles - Equations, Central & Inscribed Angles
Quiz
•
9th - 12th Grade
46 questions
Unit 4 Geosphere Test Review
Quiz
•
9th - 12th Grade
25 questions
Early Cold War Quizziz
Quiz
•
11th Grade
10 questions
Climate Change and Its Impact
Interactive video
•
9th - 12th Grade
35 questions
Venn Diagrams, Theoretical, & Experimental Review
Quiz
•
9th - 12th Grade
20 questions
Food Chains and Food Webs
Quiz
•
7th - 12th Grade