0% found this document useful (0 votes)
23 views6 pages

Chapter 2: Python Modules Overview

Uploaded by

Brako Kennedy
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)
23 views6 pages

Chapter 2: Python Modules Overview

Uploaded by

Brako Kennedy
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

MT WTFS S

Page No.:
YOUVA
Date:

Ghapter 2Modulks
Gonment & p
2-1 Modules in Puthon i
Modules provide. auua to orqanize your codle loqically
Instead oE having all your code. in a single. fihe you
Cdn split it into mutigle madules based on theix purpose

Fox example. you miaht haye one. module for handling


input Joutput' operations, ancther or mathematical
cdlculatiobs._.and another sor data manipulatian
JAhen you want ta u_e te functianality foma module,
you can impart it into Your cunen! progtcm or another
'module
This allous you to,_ accesS and se the funcians ,classes
and variables deined within that madule. B4 importing
a module you can qvoid wrting the samecode
repeaBedls_'and instedd 1euse She code deßined
inthe odule

@ rious-proqiammer
ML [Link]
Page No.:
YOUVA
Date:

22 Three Main Types of Modules


Modules

Built -in External User- defioed


modules Madules Modules

Built -in modules:


These are modules that come pre- installed uith
[Link] are patt of the stanzaucd libians and provide
la wide Iahge of funcianalities:
"Examples include modules like math for mathematical
operations,Iandom fou qeneratinq tandorn numbers
Ddte Tine for woiking wth daBe and timesang as
ior naacling uh 'he openaing gsBan.
Built-in nmodules are. leadlils_ quailable far use. with
out the heed for additanal ostallatians.

IEsternal Modules:
" These. are. modules that ae Credted bå third-pat
deuelopers and gre hgt part of the stdndatd libdis.

Qcuious-poqiaine
MT W TFSS
Page No.:
YOUVA
Date:

They exlend Aghan's capabiliics by _proviing additi


ana [Link] for speciic purpase. Exteinal
modules can be dounloded and installed using pack
ages managers like pip (Pgthon Packaqe. Index)
"Popular external modules indade numpy foy nurmerical
Coaputatians pandas for data manipulaion and
analysis. maslolib fo data visaltzation dnd
Tequests for making Htre Tequests
User - Defined Modules:
These. ane_modules cieated by the iython progammes.
hemselves. hey allow users to arqanize' their code
into sepiate files and 1euse. tunciandlity acrOSS
muliple pragams.
Wser-deiined modules_can contain [Link]
[Link] othex code that can. be imported and
used in cthex Rython scuipts ot modules
a3 Comments in Python.
Conmnens in Pyton are used to piovide erplanatozs
notes Iitthin the code Hhat aie not exeauted oz ne

Qutuous-ploqramne
MT W T F S

Page No.:
YOUVA
Date:

They are helpful fo impraxing_ code readabilts and for


leaving reminders oi ekplanations fo ather'developers
wha night woak with the code in the future
In Pgthon Comments are denoted by the hash symbol(#)
follouwed by the comment hext
H's igportant to noe that comments are meant for
human xeacders and are nat executed by the Pyhon.
inkerpreter Thergfoxe they have no impact on he
pIogram's Funchionalits & pertoarmance

pes of Comments

Malti-line
Single-line.
Comment LComment

1 Sinqle line Conments


are Used to [Link].
Sinale-line Coaments single
notes or omments on a line of

They shat with a hash Symbol ) and cotintue, untill


the end oF he line.
Qurious-proqiamme
MT W TF S S
Page No.
YOUVA
Date:

Anything auitBen afer he bash sumbol is considered


a ommert and is iqnored by the Rythan interpreter
Here 's an example:
# This is a single-line. Comment
X=5 Assianinga value to the vaaiabe x

|2: Multi-line Comments


Muti-line Comments,also known as block comments
allou you to add conmments hat span muHiple
lines

Pgthon does not have a built -in syntak sperificalls.


for multi-line. comments, b you can achieve. thisg
hy using hiple quctes (eithex'sinale ox doube quctes)
tocteate hing- 4hat is a not assigned to an
Vaxiable,. Sinctis that not (sed elseuhere io
Hhe code,t acs as a comment
Here's an eximpe'

This is o muti-line comment


t Can Span QcKosS matiple Ihes
QCUTOUS-. proqrammer
MT WT FS S

Page No.:
YOUVA
Date:

23 What is a pip
In Simple terms,pip isis aapackage
package fox Aython- H
Sands o "Rip istals Pakags" ox "Rp Jnstalls
Python' Pakagss
When working with Pahon. you my need to use. externa
libiaries or madules that pioride'additional funcionali
ies beuond what the standazd libas aters. These
libigies are often developed by the Python ommuntt4
and are Qyatlable tor andone. fo (se
Pp makes t eass to install,nanage. and unistall
these extenal haaies
bxanes Hhelgs you find and
download the libaxies yoL need fian the Rghon.
Packaqe Index (pyp) ohich is arepositox of
Pathon packages maintained by the community
coanmaaiks
pip. you can instal aapackage by tunninq a
simple cofamand in soutr Beiminal ox command

QCuvious-progiamner

You might also like