Modules Structures in Python
Programming
Dr. K.VENKATARAMANA
Associate Professor,
Dept of Computer Science & Systems Engineering
Andhra University
1
What are the Python Modules?
• A Python module is a Python file with .py extension
including statements and definitions. It contains code
that you can reuse in several programs.
• This file can contain a group of classes,
methods, functions and variables.
Python Lists
Different Built – in modules
• A large number of pre-defined functions are also available as a part
of libraries bundled with Python distributions.
• These functions are defined in modules are called built-in modules.
Built-in modules are written in C and integrated with the Python
shell. Random
Math
Time
Os
Shutil
Sys
Re
Statistics
Random Module:
Math Module:
Statistics Module:
Date and Time Module:
Date and Time Module:
Time Module:
• The time module in Python provides functions for handling time-related
tasks. The time-related tasks includes, reading the current time, formatting
time, sleeping for a specified number of seconds and so on.
Cont..
OS Module
Sys Module: The sys module provides functions and variables used to
manipulate different parts of the Python runtime environment.
Cont..
re Module
Cont..
re Module
Different ways to import Python Modules
Different ways to import Python Modules
Different ways to import Python Modules
Custom Modules
For example you want to create your own module (custom module) that contains
classes, variables, methods and so on as shown below.
And saved as .py extension
Procedure to execute Custom Modules in Colab
Python Lists