Unit 15 Flashcards

1
Q

15.1 - Reading Files

What does open() do?

A

retrieves input based on a file

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

15.1 - Reading Files

What is the difference between xfile.read() and xfile.readlines()?

A

.read returns ALL file contents into a string
.readlines returns a list with each element as a line from the text

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

15.2 - Writing Files

What does xfile.write() do?

A

writes a string argument to a file

use \n to actually write it to the file

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

15.2 - Writing Files

What are the three modes for editing a file?

A

r = reading
w = write (over)
a = append

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

15.3 - Interacting with File Systems

What is portability?

A

the ability to access an item easily from multiple locations

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

15.4 - Binary Data

What is binary data?

A

data stored in a sequence of bytes

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

15.4 - Binary Data

What is a bytes object?

A

a sequence of single byte values

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

15.5 - The “With” Statements

What is a with statement?

A

a function-like series of code that occurs while a file is opened; automatically closes once completed

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