SlideShare a Scribd company logo
Python Modules
• Modular programming refers to the process of breaking a
large, unwieldy programming task into separate, smaller,
more manageable subtasks or modules. Individual modules
can then be cobbled together like building blocks to create a
larger application.
• There are several advantages to modularizing code in a
large application:
Simplicity: Rather than focusing on the entire problem at hand, a
module typically focuses on one relatively small portion of the
problem. If you’re working on a single module, you’ll have a smaller
problem domain to wrap your head around. This makes
development easier and less error-prone.
• Maintainability: Modules are typically designed so that they enforce logical
boundaries between different problem domains. If modules are written in a
way that minimizes interdependency, there is decreased likelihood that
modifications to a single module will have an impact on other parts of the
program. (You may even be able to make changes to a module without having
any knowledge of the application outside that module.) This makes it more
viable for a team of many programmers to work collaboratively on a large
application.
• Reusability: Functionality defined in a single module can be easily reused
(through an appropriately defined interface) by other parts of the application.
This eliminates the need to duplicate code.
• Scoping: Modules typically define a separate namespace, which helps avoid
collisions between identifiers in different areas of a program.
Python Modules:
• There are three different ways to define a module in
Python:
• A module can be written in Python itself.
• A module can be written in C and loaded dynamically at run-
time, like the re (regular expression) module.
• A built-in module is intrinsically contained in the interpreter,
like the itertools module.
The import Statement
• Module contents are made available to the caller with the
import statement. The import statement takes many
different forms, shown below.
import <module_name>
The simplest form is the one already shown above:
import <module_name>
from <module_name> import
<name(s)>
• An alternate form of the import statement allows individual
objects from the module to be imported directly into the
caller’s symbol table:
• from <module_name> import <name(s)>

More Related Content

Similar to Modules and its usage in python for beginners (20)

PDF
Modules and Packages in Python_Basics.pdf
RavindraTambe3
 
PDF
Python modules
Learnbay Datascience
 
PPTX
Python module 3, b.tech 5th semester ppt
course5325
 
PDF
Modules 101
gjcross
 
PDF
Summer Training Project.pdf
Lovely professinal university
 
PPTX
Python for dummies
Roberto Stefanetti
 
PPTX
Modules in Python Programming
sambitmandal
 
PPTX
PYTHON FOR BEGINNERS (BASICS OF PYTHON)
HemaArora2
 
PPTX
Python programming workshop session 4
Abdul Haseeb
 
PPTX
Python-Mastering-the-Language-of-Data-Science.pptx
dmdHaneef
 
PPTX
Functions in Python
Kamal Acharya
 
PDF
Python for katana
kedar nath
 
PPTX
Python training
Kunalchauhan76
 
PPTX
pythontraining-201jn026043638.pptx
RohitKumar639388
 
PPTX
Class 12 CBSE Chapter: python libraries.pptx
AravindVaithianadhan
 
PDF
Python libraries
Prof. Dr. K. Adisesha
 
PPTX
Chapter - 4.pptx
MikialeTesfamariam
 
PPTX
Object oriented programming design and implementation
afsheenfaiq2
 
PDF
Python Foundation – A programmer's introduction to Python concepts & style
Kevlin Henney
 
Modules and Packages in Python_Basics.pdf
RavindraTambe3
 
Python modules
Learnbay Datascience
 
Python module 3, b.tech 5th semester ppt
course5325
 
Modules 101
gjcross
 
Summer Training Project.pdf
Lovely professinal university
 
Python for dummies
Roberto Stefanetti
 
Modules in Python Programming
sambitmandal
 
PYTHON FOR BEGINNERS (BASICS OF PYTHON)
HemaArora2
 
Python programming workshop session 4
Abdul Haseeb
 
Python-Mastering-the-Language-of-Data-Science.pptx
dmdHaneef
 
Functions in Python
Kamal Acharya
 
Python for katana
kedar nath
 
Python training
Kunalchauhan76
 
pythontraining-201jn026043638.pptx
RohitKumar639388
 
Class 12 CBSE Chapter: python libraries.pptx
AravindVaithianadhan
 
Python libraries
Prof. Dr. K. Adisesha
 
Chapter - 4.pptx
MikialeTesfamariam
 
Object oriented programming design and implementation
afsheenfaiq2
 
Python Foundation – A programmer's introduction to Python concepts & style
Kevlin Henney
 

More from Mohammad Usman (17)

PPTX
Transformation in Education from past to current
Mohammad Usman
 
PDF
AI for Data Analysis and Visualization.pdf
Mohammad Usman
 
PDF
Lists and its functions in python for beginners
Mohammad Usman
 
PPTX
Credit Card Fraud Detection Using AI.pptx
Mohammad Usman
 
PPTX
Exploring Search Engines and their usage online
Mohammad Usman
 
PPTX
Web Technologies Types available on the internet
Mohammad Usman
 
PPTX
AI open tools for Research.pptx
Mohammad Usman
 
PPTX
Open AI Tools for Data Analytics
Mohammad Usman
 
PDF
Data structures and algorithms
Mohammad Usman
 
PDF
Object oriented programming with c++
Mohammad Usman
 
PPTX
Dynamic memory allocation
Mohammad Usman
 
DOCX
Career Guide
Mohammad Usman
 
DOCX
C areer banner
Mohammad Usman
 
DOCX
Career counselling banner
Mohammad Usman
 
DOCX
Career ccc
Mohammad Usman
 
DOCX
Career ccc hindi
Mohammad Usman
 
PPT
Literacy for or_against_the_poor_seminar
Mohammad Usman
 
Transformation in Education from past to current
Mohammad Usman
 
AI for Data Analysis and Visualization.pdf
Mohammad Usman
 
Lists and its functions in python for beginners
Mohammad Usman
 
Credit Card Fraud Detection Using AI.pptx
Mohammad Usman
 
Exploring Search Engines and their usage online
Mohammad Usman
 
Web Technologies Types available on the internet
Mohammad Usman
 
AI open tools for Research.pptx
Mohammad Usman
 
Open AI Tools for Data Analytics
Mohammad Usman
 
Data structures and algorithms
Mohammad Usman
 
Object oriented programming with c++
Mohammad Usman
 
Dynamic memory allocation
Mohammad Usman
 
Career Guide
Mohammad Usman
 
C areer banner
Mohammad Usman
 
Career counselling banner
Mohammad Usman
 
Career ccc
Mohammad Usman
 
Career ccc hindi
Mohammad Usman
 
Literacy for or_against_the_poor_seminar
Mohammad Usman
 
Ad

Recently uploaded (20)

PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PDF
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Horarios de distribución de agua en julio
pegazohn1978
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Ad

Modules and its usage in python for beginners

  • 2. • Modular programming refers to the process of breaking a large, unwieldy programming task into separate, smaller, more manageable subtasks or modules. Individual modules can then be cobbled together like building blocks to create a larger application. • There are several advantages to modularizing code in a large application: Simplicity: Rather than focusing on the entire problem at hand, a module typically focuses on one relatively small portion of the problem. If you’re working on a single module, you’ll have a smaller problem domain to wrap your head around. This makes development easier and less error-prone.
  • 3. • Maintainability: Modules are typically designed so that they enforce logical boundaries between different problem domains. If modules are written in a way that minimizes interdependency, there is decreased likelihood that modifications to a single module will have an impact on other parts of the program. (You may even be able to make changes to a module without having any knowledge of the application outside that module.) This makes it more viable for a team of many programmers to work collaboratively on a large application. • Reusability: Functionality defined in a single module can be easily reused (through an appropriately defined interface) by other parts of the application. This eliminates the need to duplicate code. • Scoping: Modules typically define a separate namespace, which helps avoid collisions between identifiers in different areas of a program.
  • 4. Python Modules: • There are three different ways to define a module in Python: • A module can be written in Python itself. • A module can be written in C and loaded dynamically at run- time, like the re (regular expression) module. • A built-in module is intrinsically contained in the interpreter, like the itertools module.
  • 5. The import Statement • Module contents are made available to the caller with the import statement. The import statement takes many different forms, shown below. import <module_name> The simplest form is the one already shown above: import <module_name>
  • 6. from <module_name> import <name(s)> • An alternate form of the import statement allows individual objects from the module to be imported directly into the caller’s symbol table: • from <module_name> import <name(s)>