S7 - 33 Arrays, tupules and records Flashcards

1
Q

what is an array?

A

A finite, ordered set of elements of the same type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what does an array do?

A

An array holds a finite set of elements which are then assigned with an index number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how can we reference any element in an array?

A

by entering an integer in square brackets in front of a variable.

e.g.
birdname = [“robin”, “blackbird”, “pigeon”]

birdname [2] = pigeon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how can we return the length of an array?

A

cars = [“porsche”, “lamborghini”, “mclaren”,]

cars - this is an array and holds all these strings

the function len[cars] will assign an integer (this shows how many cars it holds)

e.g.

numcars = len[cars]
print(numcars) # it will print the integer 3 on the screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

LOOK AT PSEUDOCODE IN PAGE 180

To find the position of a bird in an array

A

page 180

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what are the 2 arrays?

A

+ 1-dimensional array
+ 2-dimensional arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how many dimensions can an array have?

A

An array can have 2 or more dimensions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

list 4 elementary data types

A

+ integer
+ real
+ boolean
+ char

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is a tuple?

A

An ordered set of values that could be elements of any type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

whats the difference between arrays and a tupule

A

Unlike arrays, the elements do not all have to be the same time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

a tuple is immutable, what does this mean?

A

like a string the elements cannot be changed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

state the advantages and disadvantages of a tuple

A
  • elements cannot be changed
  • isn’t dynamic, cannot add or remove items

+ elements do not all have to be the same type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly