Topic 3 - Persistence & Inheritance Flashcards

1
Q

File Input and Output

A

The process of opening a file, processing it by writing or reading data, and closing the file

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

Persistence

A

The ability of a program to save data for later use

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

Binary files

A

Data not encoded as text, not human readable

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

Text files

A

Data encoded as text as a series of characters, human readable

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

Sequential Access

A

Accessing data from the beginning of the file to the end of the file

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

Direct Access

A

Jumping directly to any piece of data in the file without reading the data that comes before it

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

File object

A

An object associated with a specific file that provides a way for the program to work with the file

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

Open() function

A

Used to open a file, given its file name and the operation mode

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

‘r’ mode

A

Read mode, file cannot be changed

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

‘w’ mode

A

Write mode, new file will be created

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

‘a’ mode

A

Append mode, data will be appended to the end of the file

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

write() method

A

Used to write a string to the file

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

close() method

A

Used to close the file object

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

read() method

A

Used to read the entire content from the file

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

readline() method

A

Used to read line by line from the file

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

Detecting End of File

A

Calling readline() before entering a while loop to test for empty string, or using a for loop

16
Q

Shelve

A

Python object persistence, a dictionary-like object for persistent storage

17
Q

shelve.open()

A

Used to open a persistent storage for reading and writing, creating it if it doesn’t exist

18
Q

db[‘key’]

A

Used to store and retrieve data in the underlying database

19
Q

db.close()

A

Used to close the underlying database when it is not in use

20
Q

Exception

A

An error that occurs while a program is running

21
Q

try/except statement

A

Used to handle exceptions gracefully

22
Q

else clause

A

Executed if no exceptions are raised

23
Q

finally clause

A

Ensures that certain code is always executed, regardless of whether an exception is raised or not