
Lists
Presentation
•
Computers
•
9th - 12th Grade
•
Medium
N Ellis
Used 2+ times
FREE Resource
21 Slides • 11 Questions
1
Data structures: Arrays (Lists) and records
2
3
4
5
6
7
8
9
10
11
12
For those of you who program in Python:
Python doesn’t have arrays – it has lists!
In theory, they are NOT the same!
You must be aware of this for your exam!
An ‘Array’ is collection of data WHICH HAS THE SAME DATA TYPE.
An ‘Array’ uses a STATIC AREA OF MEMORY and therefore we need to STATE HOW BIG THE ARRAY NEEDS TO BE and WHAT TYPE OF DATA IT WILL HOLD before data is added to it. An array therefore CANNOT GROW OVERTIME– you CAN’T APPEND DATA to it!
13
For those of you who program in Python:
Python doesn’t have arrays – it has lists!
In theory, they are NOT the same!
You must be aware of this for your exam!
A ‘List’ on the other hand can contain data which DOESN’T HAVE TO BE OF THE SAME DATA TYPE.
A ‘List’ uses memory DYNAMICALLY, which means that it uses different areas of memory if it needs to and as a result CAN GROW– DATA CAN BE APPENDED (added) to it!
14
15
16
17
18
19
20
21
Records
As we learnt earlier, arrays can only store data of the same type. For example, an array may store only string data, or integer data, but it cannot contain a mix of data types.
Records however, are a data structure that allows different types of data to be stored together.
This would be really useful when storing data about a person, such as a person’s name (string), age (integer) and whether or not they liked Marmite (Boolean).
22
Multiple Choice
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList = [John, Harry, Jesse, John, Harry, Harry]
23
Multiple Choice
List items have an index number. In the following list, which item has the index number of 3?
["Joe", "Harry", "Jesse", "John", "Harry", "Harry"]
"John"
"Harry"
"Jesse"
"John"
24
Multiple Choice
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList()
nameList[1]
NameList(4)
nameList["4"]
25
Multiple Choice
The list needs one more name added to the end - "Felipe". Which piece of code below would do this?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList.append(Felipe)
append(nameList,"Felipe")
nameList.append["Felipe",7]
nameList.append("Felipe")
26
Multiple Choice
27
Multiple Choice
28
Multiple Choice
Is this the correct code for a list?
register = {"Sam", "Pheobe", Georgia", Richard"}
Yes
No
29
Multiple Choice
To print a list called fruitList we use
print(fruitList)
list(print)
fruitList.print()
fruitList(print)
30
Multiple Choice
Which colour will be replaced with yellow?
red
green
blue
none, yellow will be added to the list
31
Multiple Choice
Which symbols are used to open and close a list?
( ) round brackets
( ) curly brackets
[ ] square brackets
" " speech marks
32
Multiple Choice
Consider the list:
myList=["red", "orange", "yellow"]
What would the following statement print?
print(myList[2])
This is a value Index Error
yellow
orange
red
Data structures: Arrays (Lists) and records
Show answer
Auto Play
Slide 1 / 32
SLIDE
Similar Resources on Wayground
24 questions
history of computers
Presentation
•
10th - 12th Grade
26 questions
Data Sampling
Presentation
•
9th - 12th Grade
27 questions
Annotating Texts
Presentation
•
9th - 12th Grade
24 questions
Blender - Cloth - SKR
Presentation
•
9th - 12th Grade
26 questions
Security 1.1
Presentation
•
9th - 12th Grade
24 questions
VGD CONTENT
Presentation
•
9th - 12th Grade
24 questions
The Promotional Mix
Presentation
•
9th - 12th Grade
24 questions
Peer Teaching Materi 2 3 KKA Fase E
Presentation
•
9th - 12th Grade
Popular Resources on Wayground
10 questions
HCS SCI 03 Summer School Review 4
Quiz
•
3rd Grade
11 questions
HSMS - Standard Response Protocol
Quiz
•
6th - 8th Grade
16 questions
1.1-1.2 Quiz Review
Quiz
•
9th - 12th Grade
12 questions
Exponent Expressions
Quiz
•
6th Grade
20 questions
Adding and Subtracting Integers
Quiz
•
6th - 7th Grade
11 questions
Northeast States
Quiz
•
3rd - 4th Grade
10 questions
Characterization
Quiz
•
3rd - 7th Grade
10 questions
Common Denominators
Quiz
•
5th Grade