All certifications / PCAP / Lessons
PCAP PCAP-31-03 lessons
Study PCAP for free
A week-by-week plan with every lesson, quizzes, checkpoint tests, a practice exam and hands-on labs.
Open the PCAP study planA week-by-week plan with every lesson, quizzes, checkpoint tests, a practice exam and hands-on labs.
Domain 1: Modules and Packages
- Import variants: import, import as, from … import, from … import *, and what each puts in the namespace
- Qualifying names in nested modules and packages (package.subpackage.module.name)
- Dir() to list the names a module defines
- Sys.path: where Python searches for modules and how to extend it at runtime
- Math module: ceil(), floor(), trunc(), factorial(), hypot(), sqrt()
- Random module: random(), seed(), choice(), sample()
- Platform module: platform(), machine(), processor(), system(), version(), python_implementation(), python_version_tuple()
- __name__ and the if __name__ == "__main__" idiom
- __pycache__ and compiled .pyc files
- Package layout: directories, __init__.py, nested packages and private (_name) module variables
Domain 2: Exceptions
- Try/except, multiple except branches and the order they are checked
- Catching several exceptions in one branch: except (E1, E2)
- Except … as e and the args attribute
- Else and finally branches and when each runs
- The built-in exception hierarchy: BaseException, Exception, ArithmeticError, LookupError, and their subclasses
- Raise, raise with an instance, and a bare raise to re-raise
- Assert and AssertionError
- Why except Exception does not catch KeyboardInterrupt or SystemExit
- Defining your own exception classes and adding attributes to them
Domain 3: Strings
- Character encoding: ASCII, Unicode, code points, UTF-8
- Ord() and chr()
- String literals and escape sequences (\n, \t, \\, quotes)
- Indexing, negative indexing and slicing, including steps
- Immutability: why item assignment fails
- Iterating over strings; in and not in
- Concatenation, replication and comparison of strings (and why comparing strings with numbers using < fails)
- Character tests: isdigit(), isalpha(), isalnum(), isspace(), isupper(), islower()
- Join(), split(), find(), rfind(), index(), and the difference between find and index
- Sorted() on strings versus list.sort()
Domain 4: Object-Oriented Programming
- Core ideas: class, object, attribute, method, encapsulation, inheritance, superclass and subclass
- Instance variables versus class variables: declaring, initializing and sharing
- The __dict__ attribute of objects and classes
- Private attributes and name mangling (__name becomes _ClassName__name)
- Methods and the self parameter; constructors (__init__) with default arguments
- Introspection: hasattr(), type(), __name__, __module__, __bases__, __class__
- Single and multiple inheritance, method overriding and super()
- Method resolution order (MRO), diamonds and inconsistent hierarchies
- Isinstance(), issubclass(), and the is / is not operators versus ==
- Polymorphism and the __str__() method
Domain 5: Miscellaneous
- List comprehensions, including if filters and nested loops
- Lambda functions and functions that take a lambda as an argument
- Map() and filter(), and the fact that they return one-shot iterators
- Closures: inner functions that remember variables from an enclosing scope, and late binding
- Generators: yield, next(), and StopIteration
- File I/O: open() modes (r, w, a, x, b, t, +), text versus binary
- Stream handles and the predefined streams sys.stdin, sys.stdout, sys.stderr
- Read(), readline(), readlines(), write(), readinto() with bytearray, close() and with
- Errno values (for example ENOENT, EACCES) on I/O errors