Week 4 - Arrays & Filehandling Flashcards

1
Q

Array

A

A container that can hold multiple variables at once.

However, these values must all be of the same type (Eg: all strings, all ints)

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

Multidimensional Arrays

A

Having an array inside of an array.

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

Dynamic Arrays

A

Arrays with no set size, meaning you can continue to add values to them.

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

What are the pros and cons of dynamic arrays?

A

+ They are more flexible
+ Values can be decided in the index position or be put on the end

  • The performance isn’t as good as hard coded because the computer has to calculate the memory needed constantly.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Rubbish Data

A

Values that we haven’t assigned but take up storage.

Often the case in Ruby, but will often crash programs in C.

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

Means to ‘append’.

This means to put the value onto the end of the array.

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

What number do arrays begin indexing from?

A

0

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

How do we find the number of items in an array?

A

Using .length

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

What is the best practice sequence with file handling?

A

Open the file, read/write the file, close the file then continue on with other tasks.

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

What are the cycle methods used in Gosu?

A

draw(), update() and button_down(id)

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

What’s an alternative to button_down() in Gosu?

A

Using the update() cycle

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

What does my_array[i] = gets mean?

A
  • It means to assign the value of i to the value in the loop.
  • When i=0, it will choose the first element in the array.
  • When i=1, it will choose the second element in the array
  • More notes on “fill an array” part of the lecture notes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you open a file to read/write

A

a_file = File.new(file_name, “r”)

a_file = File.new(file_name, “w”)

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