0% found this document useful (0 votes)
7 views11 pages

Day 2 Python Basic To Advanced Modules, Comments & Pip 250309 181046

The document covers Python modules, types of modules, comments in Python, and the package manager pip. It explains the organization of code using modules, distinguishing between built-in, external, and user-defined modules. Additionally, it describes the purpose of comments for code readability and provides an overview of pip for managing external libraries.

Uploaded by

Vikrant Kadam
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)
7 views11 pages

Day 2 Python Basic To Advanced Modules, Comments & Pip 250309 181046

The document covers Python modules, types of modules, comments in Python, and the package manager pip. It explains the organization of code using modules, distinguishing between built-in, external, and user-defined modules. Additionally, it describes the purpose of comments for code readability and provides an overview of pip for managing external libraries.

Uploaded by

Vikrant Kadam
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
You are on page 1/ 11

Today’s Topics:

Modules in Python
Types of Modules
Comments in Python
PIP

By @Curious_.programmer

CodeWithCurious.com
Chapter 2: Modules,
Comment & Pip
Made By:

Yadneyesh (Curious Coder) Find More PDFs on Our Telegram Channel


CodWithCurious.com Search Curious_Coder on Telegram

2.1 Modules in Python:


Modules provide a way to organize your code logically.
Instead of having all your code in a single file, you can
split it into multiple modules based on their purpose
.
For example, you might have one module for handling
input/output operations, another for mathematical
calculations, and another for data manipulation.

When you want to use the functionality from a module,


you can import it into your current program or another
module.

This allows you to access and use the functions, classes,


and variables defined within that module. By importing a
module, you can avoid writing the same code repeatedly
and instead reuse the code defined in the module.
2.2 Three Main Types of Modules

Modules

Built-in Modules External Modules User-Defined Modules

Built-in Modules:

These are modules that come pre-installed with Python.


They are part of the standard library and provide a wide
range of functionalities.

Examples include modules like math for mathematical


operations, random for generating random numbers,
DateTime for working with dates and times, and os for
interacting with the operating system.

Built-in modules are readily available for use without the


need for additional installations.
External Modules:

These are modules that are created by third-party


developers and are not part of the standard library.

They extend Python's capabilities by providing additional


functionalities for specific purposes. External modules can
be downloaded and installed using package managers
like pip (Python Package Index).

Popular external modules include numpy for numerical


computations, pandas for data manipulation and
analysis, matplotlib for data visualization, and requests
for making HTTP requests.

User-Defined Modules:

These are modules created by the Python programmers


themselves. They allow users to organize their code into
separate files and reuse functionality across multiple
programs.

User-defined modules can contain functions, classes,


variables, and other code that can be imported and used
in other Python scripts or modules.
2.3 Comments in Python
Comments in Python are used to provide explanatory
notes within the code that are not executed or interpreted
by the computer.

They are helpful for improving code readability and for


leaving reminders or explanations for other developers
who might work with the code in the future.

In Python, comments are denoted by the hash symbol (#)


followed by the comment text.

It's important to note that comments are meant for


human readers and are not executed by the Python
interpreter. Therefore, they have no impact on the
program's functionality or performance.

Types of Comments

Single-Line Comment Multi-Line Comment


1. Single-line comments:
Single-line comments are used to add explanatory notes
or comments on a single line of code.

They start with a hash symbol (#) and continue until the
end of the line.

Anything written after the hash symbol is considered a


comment and is ignored by the Python interpreter.
Here's an example:

2. Multi-line comments:
Multi-line comments, also known as block comments, allow
you to add comments that span multiple lines.

Python does not have a built-in syntax specifically for


multi-line comments, but you can achieve this by using
triple quotes (either single or double quotes) to create a
string that is not assigned to any variable. Since it is not
used elsewhere in the code, it acts as a comment.
Here's an example:

2.3 What is a pip?


In simple terms, pip is a package manager for Python. It
stands for "Pip Installs Packages" or "Pip Installs Python."

When working with Python, you may need to use external


libraries or modules that provide additional functionalities
beyond what the standard library offers. These libraries are
often developed by the Python community and are
available for anyone to use.

Pip makes it easy to install, manage, and uninstall these


external libraries. It helps you find and download the
libraries you need from the Python Package Index (PyPI),
which is a repository of Python packages maintained by
the community.

With pip, you can install a package by running a simple


command in your terminal or command prompt.
Will Post Tomorrow Follow For More
for Handwritten Notes Search
“CodeWithCurious Store” on Google

CodeWithCurious Store

You might also like