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

A

with

17
Q

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

A

as

18
Q

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

A

Modules

19
Q

The ___ module enables running system commands

A

OS

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

A

r

23
Q

changes the working directory

A

os.chdir ( )

24
Q

creates a directory

A

os.mkdir ( )

25
Q

removes a directory

A

os.rmdir ( )

26
Q

renames a file

A

os.rename ( )

27
Q

gets the location of the working directory

A

os.getcwd ( )

28
Q

maps folders and files

A

os.walk ( )

29
Q

provides information about files and directories and performs a statistical system call

A

os.stat( )

30
Q

includes classes for date and time

A

datetime

31
Q

is used to access data related to the OS and Hardware

A

platform

32
Q

the _____ module enables generation of pseudo-random numbers

A

random

33
Q

returns a random integer in the range that appears in parenthesis

A

.randint(x,y)

34
Q

to open a file

A

open( )

35
Q

use a ____ loop to read the file’s text line by line

A

for

36
Q

use __ to choose which information to remove

A

split ( )