
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
26 questions
Bit rate, bandwidth, & latency
Presentation
•
9th - 12th Grade
24 questions
Data Types, Addition, and Errors
Presentation
•
9th - 12th Grade
24 questions
Lesson 6-2: Kites and Trapezoids
Presentation
•
9th - 12th Grade
27 questions
Cold War (Intro)
Presentation
•
9th - 12th Grade
27 questions
Discrete and Continuous Data
Presentation
•
9th - 12th Grade
26 questions
Canada Map 3
Presentation
•
9th - 12th Grade
20 questions
2.1 Computer Systems
Presentation
•
9th - 12th Grade
25 questions
Intro to HTML 1
Presentation
•
9th - 12th Grade
Popular Resources on Wayground
5 questions
A Home on the Shore
Quiz
•
3rd Grade
28 questions
US History Regents Review
Quiz
•
11th Grade
6 questions
A Horse Tale
Quiz
•
3rd Grade
20 questions
Math Review
Quiz
•
3rd Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
20 questions
Dividing Fractions
Quiz
•
5th Grade
55 questions
A Long Walk to Water Final Review
Quiz
•
6th - 8th Grade
10 questions
Equation Word Problems
Quiz
•
7th Grade
Discover more resources for Computers
28 questions
US History Regents Review
Quiz
•
11th Grade
20 questions
Insurance
Quiz
•
9th - 12th Grade
10 questions
Juneteenth: History and Significance
Interactive video
•
7th - 12th Grade
10 questions
7.3-7.4 Quiz
Quiz
•
11th Grade
20 questions
Summer Geometry QUIZ (Week 2)
Quiz
•
9th Grade
6 questions
Mayan Mathematics part 1
Presentation
•
9th - 12th Grade
25 questions
Biology Regents Review
Quiz
•
9th Grade
40 questions
Flags of the World
Quiz
•
KG - Professional Dev...