Search Header Logo
Lists

Lists

Assessment

Presentation

Computers

9th - 12th Grade

Medium

Created by

N Ellis

Used 2+ times

FREE Resource

21 Slides • 11 Questions

1

Data structures: Arrays (Lists) and records

2

media

3

media

4

media

5

media

6

media

7

media

8

media

9

media

10

media

11

media

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

media

15

media

16

media

17

media

18

media

19

media

20

media

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).


media

22

Multiple Choice

Which of these is the correct code for creating a list of names?

1

nameList = John, Harry, Jesse, John, Harry, Harry

2

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

3

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

4

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"]

1

"John"

2

"Harry"

3

"Jesse"

4

"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"]

1

nameList()

2

nameList[1]

3

NameList(4)

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"]

1

nameList.append(Felipe)

2

append(nameList,"Felipe")

3

nameList.append["Felipe",7]

4

nameList.append("Felipe")

26

Multiple Choice

Question image
What is the position of the name "Robert" in the following list:
1
0
2
1
3
2
4
3

27

Multiple Choice

Question image
What output will this code produce?
1
blue
2
green
3
red
4
error

28

Multiple Choice

Is this the correct code for a list?

register = {"Sam", "Pheobe", Georgia", Richard"}

1

Yes

2

No

29

Multiple Choice

To print a list called fruitList we use

1

print(fruitList)

2

list(print)

3

fruitList.print()

4

fruitList(print)

30

Multiple Choice

Question image

Which colour will be replaced with yellow?

1

red

2

green

3

blue

4

none, yellow will be added to the list

31

Multiple Choice

Which symbols are used to open and close a list?

1

( ) round brackets

2

( ) curly brackets

3

[ ] square brackets

4

" " speech marks

32

Multiple Choice

Consider the list:

myList=["red", "orange", "yellow"]

What would the following statement print?

print(myList[2])

1

This is a value Index Error

2

yellow

3

orange

4

red

Data structures: Arrays (Lists) and records

Show answer

Auto Play

Slide 1 / 32

SLIDE