In: Computer Science
Functions also introduce the concept of modularity, where a
program can be broken up into multiple smaller pieces; each of
these modules contains one or more functions that can be used to
perform a small part of the overall task (and which can be reused
by other programs). Python includes a large library of modules,
each of which includes useful pre- written functions that
programmers can use in their own programs with the use of an import
statement. The “Python Standard Library” Web page, available at
<https:// docs.python.org/3/library/index.html>, contains a
full list of these “bundled” modules (the list starts at the “Text
Processing Services” bullet point and continues until the end of
the page).
In class to date, we’ve used or made reference to three of these
modules: random, string, and math. Choose TWO of the other modules
listed on the “Python Standard Library” page. For each
module:
1. Identify the name of the module and briefly summarize what
general purpose it serves.
2. Select THREE functions from this module. List each function’s
name and briefly describe what it does.
3. Give an example of a type of program (real or hypothetical) for
which this module is either essential or extremely useful.
The two other modules from the list on the "Python Standard Library" page are:
1. datetime:
Name of the module: datetime module
General purpose: This module supplies classes which contains information about date and time objects. It is used to manipulate dates and times.
Three functions:
Example: All the information (files) in a computer system from the moment it has been created is stored in the system along with its timestamp, date and time. When this data needs to be manipulated by developers, datetime module will be an absolute necessity.
2. cmath:
Name of the module: cmath module
General purpose: When dealing with complex numbers or floating point numbers, this module has all the useful methods to manipulate such types of numbers as arguements.
Three functions:
Example: With cmath python module, the half-life of an unkown radioactive element by measuring the mass at an interval.