PY-04-P1 File System and Error Handling Flashcards Preview

Python > PY-04-P1 File System and Error Handling > Flashcards

Flashcards in PY-04-P1 File System and Error Handling Deck (36)
Loading flashcards...
1
Q

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

A

Try

2
Q

____ handles an error in the try code

A

Except

3
Q

runs only if no exception occured

A

Else

4
Q

runs whether the code failed or succeeded

A

Finally

5
Q

prints a custom error message

A

Raise

6
Q

inserts an error message in a variable

A

Exception as a error

7
Q

What is a file categorized as in Python

A

text or binary

8
Q

enables access to a file for the python interpreter

A

Open( )

9
Q

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

A

close()

10
Q

writes content to an open file

A

write()

11
Q

allows reading the file according to the permission

A

read()

12
Q

is used to read a file line by line

A

readline( )

13
Q

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

A

readline ( )

14
Q

this function saves and closes a file

A

close

15
Q

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

A

flush ( )

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 ( )