PY-04-P1 File System and Error Handling Flashcards

1
Q

___ creates a code block to try to execute code that may create an error

A

Try

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

____ handles an error in the try code

A

Except

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

runs only if no exception occured

A

Else

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

runs whether the code failed or succeeded

A

Finally

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

prints a custom error message

A

Raise

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

inserts an error message in a variable

A

Exception as a error

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

What is a file categorized as in Python

A

text or binary

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

enables access to a file for the python interpreter

A

Open( )

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

must be added after open to be able to read the file and/or save changes made

A

close()

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

writes content to an open file

A

write()

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

allows reading the file according to the permission

A

read()

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

is used to read a file line by line

A

readline( )

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

can also be used to read the number of bytes from the line

A

readline ( )

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

this function saves and closes a file

A

close

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

The f____ function is used to save a file and continute editing it

A

flush ( )

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

a ___ statement will create a context manager

17
Q

The variable that contains the file is the one defined after __

18
Q

Used to break down large programs into smaller, more easily managed files

19
Q

The ___ module enables running system commands

20
Q

The ______ function allows system operations and the execution of shell commands

A

os.system( )

21
Q

lists all the files in the specified directory

A

os.listdir(path)

22
Q

the _____ before the directory insturcts the interpreter to regard the characters that follow as a raw string

23
Q

changes the working directory

A

os.chdir ( )

24
Q

creates a directory

A

os.mkdir ( )

25
removes a directory
os.rmdir ( )
26
renames a file
os.rename ( )
27
gets the location of the working directory
os.getcwd ( )
28
maps folders and files
os.walk ( )
29
provides information about files and directories and performs a statistical system call
os.stat( )
30
includes classes for date and time
datetime
31
is used to access data related to the OS and Hardware
platform
32
the _____ module enables generation of pseudo-random numbers
random
33
returns a random integer in the range that appears in parenthesis
.randint(x,y)
34
to open a file
open( )
35
use a ____ loop to read the file's text line by line
for
36
use __ to choose which information to remove
split ( )