0% found this document useful (0 votes)
4 views3 pages

Python Modules Explained for Class 11

A module in Python is a file containing code for specific tasks, aiding in code organization, reusability, and maintenance. Modules can be built-in or user-defined, with various methods for importing them into programs. Benefits of using modules include simplicity, better organization, and access to library support.

Uploaded by

Bishan Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Python Modules Explained for Class 11

A module in Python is a file containing code for specific tasks, aiding in code organization, reusability, and maintenance. Modules can be built-in or user-defined, with various methods for importing them into programs. Benefits of using modules include simplicity, better organization, and access to library support.

Uploaded by

Bishan Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MODULES IN PYTHON – CLASS 11 (CBSE)

1. What is a Module?
A module in Python is a file that contains Python code—functions, variables, and
classes—written to perform a specific task.

●​ It helps in organizing code.​

●​ Makes programs reusable and easy to maintain.​

●​ Any Python file with extension .py can be used as a module.​

Example:

A file named [Link] or [Link] is a module.

2. Why Do We Use Modules? (Benefits)


●​ Reusability: Use functions written earlier in new programs.​

●​ Simplicity: Divide a large program into smaller parts.​

●​ Avoid Repetition: Common functions kept in modules.​

●​ Better Organization: Code is cleaner and structured.​

●​ Library Support: Python provides many built-in modules.​

3. Types of Modules
1. Built-in Modules

Modules already available in Python.

Examples:

●​ math​

●​ random​

●​ datetime​

●​ statistics​

●​ os​

2. User-defined Modules

Modules created by the programmer in a separate .py file.

Example:

Creating [Link] with functions and importing it into another program.

4. Importing Modules in Python


Python provides multiple ways to import modules.

A. import module_name

import math

print([Link](25))

●​ Access functions using module_name.function_name.


●​
●​
●​ import math as m print([Link])
●​
●​ D. from module_name import *
from math import *

print(sin(0))​

You might also like