Bullet Points Flashcards
What do you use the open() BIF for?
Use the open() BIF to open a disk file, creating an iterator that reads data from the file one line at a time
What does the readline() method do?
The readline() method reads a single line from an opened file?
What is the seek() method used for?
The seek() method can be used to “rewind” a file to the beginning
What does the close() method do?
The close() method closes a previously opened file
What does the split() method do?
The split() method can break a string into a list of parts
What do we call an unchangeable, constant list in Python?
An unchangeable, constant list in Python is called a tuple.
Once the list is assigned to a tuple, it cannot be changed. Tuples are immutable.
Under what conditions does a ValueError occur?
A ValueError occurs when your data does not conform to an expected format
Under what conditions does an IOError occur?
An IOError occurs when your data cannot be accessed properly
e.g., perhaps your data file has been moved or renamed
What does the help() BIF do?
The help() BIF provides access to Python’s documentation within the IDLE shell
What does the find() method do?
The find() method locates a specific substring within another string
What does the ‘not’ condition do?
The ‘not’ keyword negates a condition
What function or mechanism does the try/except statement provide?
The try/except statement provides an exception-handling mechanism, allowing you to protect lines of code that might result in a runtime error
What does the ‘pass’ statement represent in Python?
The ‘pass’ statement is Python’s empty or null statement; it does nothing