Python Complete Notes Handwritten
Python Complete Notes Handwritten
PYTHON PROGRAMMING
UNIT-I
Python Basics: Objects- Python Objects, Standard Types, Other Built-in Types, Internal Types,
Standard Type Operators, Standard Type Built-in Functions, Categorizing the Standard Types,
Unsupported Types Numbers
Introduction to Numbers: Integers, Floating Point Real Numbers, Complex Numbers, Operators,
Built-in Functions, Related Modules
Sequences - Strings, Lists, and Tuples, Mapping and Set Types
UNIT-II
FILES: File Objects, File Built-in Function [ open() ], File Built-in Methods, File Built-in Attributes,
Standard Files, Command-line Arguments, File System, File Execution, Persistent Storage
Modules, Related Modules
Exceptions: Exceptions in Python, Detecting and Handling Exceptions, Context Management,
*Exceptions as Strings, Raising Exceptions, Assertions, Standard Exceptions, *Creating Exceptions,
Why Exceptions (Now)?, Why Exceptions at All?, Exceptions and the sys Module, Related Modules
Modules: Modules and Files, Namespaces, Importing Modules, Importing Module Attributes,
Module Built- in Functions, Packages, Other Features of Modules
UNIT-III
Regular Expressions: Introduction, Special Symbols and Characters, Res and Python
Multithreaded Programming: Introduction, Threads and Processes, Python, Threads, and the
Global Interpreter Lock, Thread Module, Threading Module, Related Modules
UNIT-IV
Database Programming: Introduction, Python Database Application Programmer’s Interface (DB-
API), Object Relational Managers (ORMs), Related Modules
UNIT-V
Numpy, Pandas,Sklearn, Matplotlib, Seaborn
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
ns lectures youtube channel
anclaas
6) Python Data Arles's
Panel Data Systorm
Pondat Stoes in à0o
wo retedb We Meknney wH
w i h
datn SS
workng
is a python b y used and manpala
Panda cesning
hol therm
aadable and elevant.
Con deon messy t a Ctsond ereke
Pardas
Pandas
ear
Amgunt o data
data
0Hong hug data, Remoe
duplicates Knin
Mack earnin
DataDaba Viuelizaton
f}nolyss
Businen and markeling
G)
hathtare Datands
Neuro Scna
Bg data
ond Seena
NLP hturek
arguagoe prousin
deta Stnichural o ns lectures youtube channel
nde o Y2
tant
opovtant
Senbs
Datathema
Seie in able.
panealSernies is lke a Caeanns a
data
One- lnensio na ro holsdng
Tta
Eornple oporPonde p e al
p
A
a,.+ a,2,3
esult peepSeno(a vt p res(a)
Pritreuult)
Pt(vl)
Oatpub
1 p
2
dtypehe6y
type Int6y
ns lectures youtube channel
KValue Objods o Srdes
whn (rakny
objd, l:ke o ho no
donay,
ou Con olao Ule a
value
K/vale
po Pordas os pd
roqyam' d o y :aoo3
aoo9
oo1:
veultp. Sres
prit veulE)
Oakpue
do
oo
otype: iot 6y
.sntch p e Specty
means
Tiswcd
1t wed 4»
fo Sele J
Seleet dort
t
besd indoey)
o c ( L t g r -Jocadbien
whih man Specty he numeriak tndix
posihon,
by
ns lectures youtube channel
ornp
imporb pordas as p
D: Lyo
d d n ' ' 10
: s ' : 20, 3 0 ,
pdSevien data
a.DocC, ' 8 ]
Co, 3.3)
Print[lo)
print ( ilo)
Otpat
3o
type
lo
D
type: nt-64
ns lectures youtube channel
import pandas a pd
,So
a 1 0 ,ao, 3o,
D 4
' : |o, Biao,
8utpu
ype: int 6y
A
P
type intG4
ns lectures youtube channel
ke a (olum
objact. Seri
iSawo imensiona aroy
Data
Rav
lmns
import Pandas a p
Bample
Pntpd. Datebvorma()
Btput
boph Dota trars
(odomns: C
Trdet C
pandad pe
blaryple import
onos:10, ao, 30
O Sa
shiva
Yamesh
ns lectures youtube channel
Head m metods
coetod
mdhod ave diplay
uuxed duploy
ponchs, t 'haadk'ond l t yousa Daboe
Feu vus and
and
hlat w
import Pandos a d
barmpa
'Suvsh'
riane' Sa', shiva', am
Aqe :a5,30,23, 3
mak 95. 7,35,22]
a= pd-Datahame(Jata)
pot a.headoo)
piot(a.tado)
Oput larn
Siva 99
aneh
Nam
S
3
Yamesh 0
Sureh
ns lectures youtube channel
eadng CSV
lonrna Spraled
t se Csv les .
bl dda Gl
s
A Sirnple wo tove
wl
oat hat
kacrwnomat
kurwn
ar
Con
s
CSv Flu otasos plan tort and
b edbpandes
port pardas p d
Data.CSV
ad sv.('Data. Ca v')
uno, age, nam a
' a s Sa
, 26, Shiva
otpu
Sai
27, ganadh
shiva
29, vamesh 9anh
29 muhb
Readng TSonles.
Notstion
Java Srpt Oljutan objert. Ln aur
etample
Read MsEal
data. jion
"":'hiva, a: ganuh p dr e a d e x c l ( 4 l e . r d s )
prsenttd Usig
cago arhy
Can be
0dared Tru
a pd Datnlyarn( dta)
prnt la)
Oredna
Octput Cesgoy
A
Mediu
A
ns lectures youtube channel
ierport pandas os pe
p.Datofrarne i o C , , 2Nama:So,'ska, v
Pa pe
Dabfant: [a.3.],'A'Aela,
Priet pdmgJ,Jo, m'To)
apu
Nem
Ag
Shiva
Odtput:
Nom Agr
Sai as
ns lectures youtube channel
OnCale natng
ata Tyome
impoxt Danda ad pd
pDatsterne
Aa- pa- D-bahen
Print
o':4.5,,sn varna',Soresh',"hassh
1)
a pd. Cnat , a, nere- ndex =ho)
Ooput JD Nam
Sa
Tamish
Suryh
ha
ns lectures youtube channel
Using'iteuternsc) enthedto
Hrate (olsns Q thoy Nalu
.
owsl
Usingtertuplst
Pgvo Using hernse
tridernsc)
Panedosopd
inpost
'Nama':.s"vermesh 'Suresh'
sata T:C,,,
Aas
ap. D.tatema (b)
hrikng () ounn
i ,Jin
prnt(" lumn: " i Yaly
Calumn 1 0
Outpu
n dame
amaAqe, dtype:iot y
yacn
S reh
npot panda as pd
doba-i':2,3 Yemu'Surb
pint
Dopu
Age
Nane: 0, dtype jeet
amelh
Neme
type : bjat
Tdu:
Narn Sursh
Age
Nerea type : ohjet
ns lectures youtube channel
impo Pansas as
Nore 'Yamash'Sarah"
aloto 'To':,1,)
Age' Cas, 1e, a2] 1
pd. Dataho(data)
a.etplasy
point()
Oatpe
pandos(Tdes so , D e '
Name ramauh'
Pan da(Tdensi, w
Suiresh' Aae ai
ns lectures youtube channel
VNora
on
Juntons
Pando Using
pondas aj pd
inpos not a oumbc
iemport upy
Nama Ag
as.o
20.0
4.0
ota Namber
Name Ag
a5.5o
.oooo0
Sai a5. 66664
amesh
2.0c00
22.00od0
NanN 30. o n r o
larme
So
O
Torneb 23.S
22
20.0
UNIT-5 PTHON ns lectures youtube channel
What is
a nparay
b:nparrayCCc, 3], CHs, c3, O:3,9]]) I 2 3
/to 12
plicationsubtracto
rogtam to perfosm matin additi oo , multi
2D Aray sing ump 2-3 3
2
import numpy as P 3 2
be
Out puti
matrix addidion!
[eu su]
matiX subtraction!
]]
You
Jndering elermernt
2 3
to t.s
nde
Can
numbe
acceSS an
byreferving
indexe s nunpy aays starts wit
The
tha t he
firs t element has index an d O,meani^
secood has
inde
Slicing ays:
elemeots fom Íne
PYtho n needs means taking
qiven 1ndex to another qiven index
import hur
umpy as nP 2 i3i
3
a2nparray (Cti213)
print (aCo u] tt u218, u
print (a[:43) +C, 2| 3tu7
print (aCo:]) # C23 u]
u7
print (a[ :3) t 2 a u]
printCal-s:-)# [2 7
print (aC:3-)# Cu 3 2
beb
print (np-lenla,b)) print np-ged (ab))
Output: Out Pud:
3
(2
fune tio0:
Output:
v a l e s
impot nurnpy as nP
EmptyAg
at npempty (a2)) 6. 36598137e -3|4
b:np.full CCa 2), ) (at2t44s79e-314
|.907962 e-313 2
334|9S3 37e-31a)
print (Empty teray \n", a) Full trray!
print ("Full ArraH:\n"b)
ns lectures youtube channel
all
and all
s ( l e d with
|(import
reatinynumpy nurnpy:3erosC) fune hon
(Co. o]
Co. o.]]
f;lled with ones:
|Arays
(.
as
irmport nunpy np
a-np 3ves ((212);dtypeint)
Prin t Ca)
Dutput:
(Co
List
’ Need to
import using ’ Inbuilt data stueture.
nurnP Enclosed in
’need to enelose using ar square brackets.
funcioo
import numpy as
b:totO5,8tech
prar ray (Ch23iu7)
(ontain elenents of contaio clements of
different types difternt ty pes.
ns lectures youtube channel
nparray CCCi,213],Cursia)
3
Can
Opetatons.
dire c+ arithmetic
Cannot appy
operations.
direct ari thrnctic
Co ns u m e s
less memo conSumes moe
mernorY
offer speeiali3ed functions >List have built in
|Aforrray numerical bperaions metho ds and funetionalies.
(o,e,2)
printle) ’ all main diagonal
o. elements
npeyel3) <qual to
o's.
printlt) [o.
.])vemaining
1np:Tandomirand (23)
o7ols3 o-6119522
print(a) Co:s3s763
Jo4os9bU
ns lectures youtube channel
in
2
print(i)
nparvay (Co,su))
print ("method br tany ndezing:ati)tt me thod u-fant indesg
prrint C"method s- boolean indexing:"a Ca»2)
tmethod sboolean indeitg
yenpwhere la)
pint("netho d6-uwhere funcehon:", ay]) L2 3
pint ("me thod ? - talke furne hon:"; nptakela,)t Ct us
Arithmetic Operations and Statigtical methods
import unpy as
Numpy'
a 2nparay(Ci213 ,4,5])
b:nparay CC6,,e,9,to])
print Cnp add (a,b)) tt (1,9 (3 15
print (np. su btrae Cayb)) # C-s -S -5 5- 5
36 so]
prin
print(np divide (ab)) # loe6 b6b1 b29s7u2q
b375
2
print (np-power Cab)) tt GSG 2621
q165625]
X: np:array (C2bia)
Print (np:mean(x)+6
(npmedian C*) +o
print
(1)
ns lectures youtube channel
atput
split tays:
-loei- (mean)
- Sea le(standaud deviahon)
- 513e - shape of
Example: Genate ran dom Distributioo
of si2e 2x3 with
mean at standad
deviaton 2
impor t random
frorn nump
Vrandomnormal (loe l stas si3el, a))
Print (x)
Dutput
Co.o7437475
buua 2
ns lectures youtube channel
Disttibutoo:
Poisson
has Palameters
Iam: bo of bccureney
si3eshape (91ge
has 2 Paraneter s
free dom
Sige: size ot ay
Ex}- raw sample for ehi squared distibuhon
deqree of tree do m wwitth S13e 2X3
MAPLOTLI6;
Malplotib vs a pouwyul tort un pythonhot halps
Creade vmal preertaioy chaib and graghs
ws made un
1) Jine plet
4) Scott plot
5) plot
6) vo Volin lot
þlt. (a19)tlottt. impovt finaly,unclion
the apetaNmeicalwing By )
xlabel Line
(x- madplotib daw to Plot
anis)" the i
i0,6])(8,e, Showt)
-pyplot hen,
chartyou
connecing
line a matplotlib
as uncan
pt
hoiyondal tow
halgs
"plotc"
employhe in
display poia.
these (xpython,
)
and
he You
chat edicallo) satp
ns lectures youtube channel
ns lectures youtube channel
yYellow
k: Blak
G 10
ns lectures youtube channel
a Bar Plot :
PAogam
pt. ShowC).
Skjedo
ns lectures youtube channel
t. alabel(" aley) A
4
ns lectures youtube channel
4) Scaten Plot
Jike a dat to dot dawing
each. det resens a paiçn ot vaes
yous data.. ît helps you ik thenes a
ulalionvhip baten tuwo aiables.
roeam
imput maatlib- pyplat ad plt
[,2,3, 4.5
i9: 2,3,1,21)
| * (2,3,5,G,J
(o.5,0, 0,0)
pu 2, (albels: y explode:2, Ahadoo Inue)
.how() aind
Vio
6) Violin Pati
cox. plet.ad a
tonel dewiiy plet
can aate a vielin plot wing
vioin plot () undi.
ns lectures youtube channel
b a3, a5)
C: [3r4,5,6]
d: (a.5,6.]
dada [ai b, Ci)
Plt. Vieinglot (dota, Nhowmudiany sTu)
pt. Ahow)
3 4 8
ns lectures youtube channel
igh-deve
"Michaal was kor ". This ravy
obon wa daulaped by
i
wo ioibally xeleaked in 3o2.and t ha aplned popularity ov
Simpichy and ePPechivenei in sesbng Statisticol Visuaahn on top
matp lot:b.
impotSeaborn as Sns
dataset.
nanes( )
name= Sns. oet-
priotnamal)
a n s o m b e ' ' a t e n t o n b r a l n _nehso iKS',Cav-(vash
outputanaqvecns, btanie'
mondS dots", 'qlue
ns lectures youtube channel
.Sns.oad detaset"ps")
priot (a)
Output:f Sex Sno Kev ine Si3e
total-b:00
Dinner 2
F No Sun
O 6-99 3
66 Sun Dione
o 34
M Sun Dinner
3 SO
3-3 N Sun Diane
3 3. 68
&42 H9 Dioner
ay 3 18-8 3.00 hu Dinne
(onns
ooedt
ps' data Sel
Drogrerm
impor Seabom o Sns duplo
method o i u
a = Sns. Doad dat«Set (-bip") headc
ony-t ve ws
Seaborn a SnS
impo
irnpost rmotplot Pyplob a
plE
oad -data Sot ( ps")
a Sns.
data
Sns (ountpot (x =" Sex", dataset ")
female in the tips
plt. tle(" (ound male and
plE.show) males ond knale
in ipi'datoset
Lount d
Ouctput
0-
20
Fenale
Mole
Se
ns lectures youtube channel
."total_L"
Proqrom o (ompae
Shipmlot wo (olnns
irmpl
ond Usinq Stir plb
20
Sa Sun
ns lectures youtube channel
0-
Scaeplo
Sat Sun
ns lectures youtube channel
Chivasiate Dishibulion
Uni Vasiate disbtim efers to . Jsilzkon SingVanable
(o)Geno
Seobom is usedto Visue he
ctptesPundtim
Chivaziate distribdim d a dataSet.
estimabe (kDE) plot
with a kvnel densthy
Jombines a m plot
output
Poqvami
Impost
Seaborn a SnS o6
pt.shawt)
otol b:0") -
03
.o AT
O.o
30
totak- : R
o.o
poStaborn a SoS
impart motplotbb- pyplet
Imper
pl .0
o C
a Sns.oad. datasct+("tips")
Sns. dpht (a taL:A"hit:False totabill
pltshuw)
witht kde plot O 6 6
Progyam-
at SoS
impo rt Seaborn
impevt matylot1:6.pyplot plt o
y 6
plt shawl)