Using Python Libraries - Revision Notes

 CBSE Class 12 Computer Science (Python)

Using Python Libraries
Revision Notes


  • Start here in points
  • A library refers to a collection of mudules that together cater to specific type of needs or applications.
  • A module is a separately saved unit whose functionality can be reused at will.
  • A function is a named block of statements that can be invoked by its name.
  • Python can have three types of functions: built-in functions, functions in modules and user-defined functions.
  • A Python module can contain objects like docstrings, variables, constants, classes, objects, statements, functions.
  • A Python module has the .py extension.
  • The doctrings are useful for documentation purposes.
  • A Python module can be imported in a program using import statement.
  • There are two forms of import statements
    1. import <modulename> [as <aliasname>]
    2. from <module> import <object>
  • The built-in functions of Python are always available; one needs not import any module for them.
  • The random module of Python provides random-number-generation functionality.
  • The urllib module lets you send and receive http requests and their results and web browser lets you open a webpage from within a Python program.
  • In order to create own package, it should be created so that it has a folder having its name and it also has a special file_init_.py in it. After this, it must be attached to site-packages folder of current Python installation.
  • A package installed or attached to site-packages folder of Python installation can easily be imported using import command.
  • Avoid using the from <module>import * form of the import statement, it may lead to name clashes. If you use plain import <module>, no problems occur.
  • Namespace is a named logical environment holding logical grouping of related objects within a namespace, its member object is referred without any prefix.
  • Module is independent grouping of code and data (variables, definitions, statements and functions).
  • Module can be re-used  in other programs.
  • The file __init__.py in a folder, indicates it is an importable package, without __init__.py, a folder is not considered a python package.