Chapter 6 Flashcards

1
Q

What is meant by “writing data to”?

A

Saving data on a file.

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

Output file

A

A file that data is written to.

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

What is meant by “reading data from?”

A

Process of retrieving data from a file.

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

Input file

A

A file from which data is read.

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

What are the 3 steps a program goes through when using a file?

A
  1. Open file.
  2. Process file.
  3. Close file.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Text file

A

Contains data that has been encoded as text.

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

Binary file

A

Contains data that has not been converted to text.

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

Name the two ways used to access data stored in a file.

A

Sequential access and direct access.

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

Sequential access

A

File read sequentially from beginning to end, can’t skip ahead.

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

Direct access

A

Can jump directly to any piece of data in the file.

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

Filename extensions

A

Short sequences of characters that appear at the end of a filename preceded by a period. The extension indicates the type of data stored in the file.

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

File object

A

Object associated with a specific file. Provides a way for the program to work with the file: file object referenced by a variable.

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

open function

A

Used to open a file. Creates a file object and associates it with a file on the disk. General format:

file_object = open(filename, mode)

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

Mode

A

String specifying how the file will be opened. Example: reading only (‘r’), writing (‘w’) and appending (‘a’)

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

Method

A

A function that belongs to an object. Performs operations using that object.

File object’s write method is used to write data to the file.
file_variable.write(string)

File should be closed using the file object close method.
file_variable.close()

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

read method

A

File object method that reads entire file contents into memory. Only works if file has been opened for reading. Contents are returned as a string.

17
Q

readline method

A

File object method that reads a line from the file. Line returned as a string, including ‘\n’

18
Q

Read position

A

Marks the location of the next item to be read from a file.