Introduction to Python ProgrammingXYZ Homework Edition

⇩ Download ▾

7.6 Chapter summary

Highlights from this chapter include:

Table 7.3 Chapter 7 reference.
StatementDescription
import moduleImports a module for use in another program.
from module import functionImports a specific function from a module.
if __name__ == "__main__":A line of code found at the end of many modules. This statement indicates what code to run if the module is executed as a program (in other words, what code not to run if this module is imported by another program).
help(module_name)Shows the documentation for the given module. The documentation includes the module's docstring, followed by a list of functions defined in the module, followed by a list of global variables assigned in the module, followed by the module's file name.
help(function_name)Shows the docstring for the given function.
date(2023, 2, 14)Creates a date object representing February 14, 2023.
Requires: from datetime import date.

Adapted from Introduction to Python Programming by OpenStax (openstax.org), licensed under CC BY-NC-SA 4.0. Changes were made. License: CC-BY-NC-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or any other accessibility standard. Every page is built against an automated accessibility gate, and our target for the published editions is WCAG 2.2 Level AA. If something is unusable, please tell us.