0% found this document useful (0 votes)
3 views13 pages

Python Data Structures and Functions

The document discusses various programming concepts in Python, including data types, functions, and control structures. It provides examples of how to manipulate strings, lists, and dictionaries, as well as error handling and algorithm implementation. Additionally, it covers the differences between compiled and interpreted languages, and introduces basic data structures such as queues and stacks.

Uploaded by

akshatghiwala08
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)
3 views13 pages

Python Data Structures and Functions

The document discusses various programming concepts in Python, including data types, functions, and control structures. It provides examples of how to manipulate strings, lists, and dictionaries, as well as error handling and algorithm implementation. Additionally, it covers the differences between compiled and interpreted languages, and introduces basic data structures such as queues and stacks.

Uploaded by

akshatghiwala08
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

classate

Date
Page

Descibe membexship d ldenify oPera by with


Ex4mple.
Membexship oPexatori

It is ysed to, Checs Vqle 1S PYese

-- In oPexqtox Returns Trye if


iF the valye
15 tomd m the Sequence

Ex Code

Hello, worla
My
Pxint
stsing wo" in my- staing)
Pxit Cumiversex" hot iin. y<sthg

-Jis =Ci.?,3, 4,5]


Prin my list
3 hn oy-
Pint C6 notja my- li5+)

Tuple
My - tupe, C4Pple, bunung "chexy ")
.

Pin n ny-tyfe
Pxin my 1pk)
clssmate
Date
Page clAssmate
Date
Page
Identifiex9Pexatar' Cxpsess the Usaye the function with
4sed to check if two V4xiqbls eX4mple.
ye fes to the S4eobjec
memoay lowex C)
’IheSC to ypp oc4se
- Is oPextox Retyn the: .tye: if.6o th |owex case
Vyxigble s xefex to the s4me
my-stiny Hello woxld
object
Ex code: HELLO, WoRLD!
object
prin (yiis b)
Dif objects Xmoves leadiny und txilny white
fxom
Prin (cisd). my- Sty : Helle, woxl!"
Pxin (C= =4) Pxint (my. stziny. Stxip )
Helloorl) !
e No ne
(3) split c)
’ The fu' splits.
Specified Stpysytax
Date
Pag
classmate
Date
Page

applk, b4hNA Chcny


EX my - stxiny c"). Diff
pri ny- staiy splh between Compilex

bangy che ny' Com filex Intex Pxetex


L'afple
-(ompilax tukes entixe Intexpxetex takes s1)
K4) Join ) list of Piogxm us imput 4le instzuctien us nput
6ncutehyts

sinyle stainy Intex mediat obiect cade No Intex medicne object


Code js 4eneZuted.
apple", barDG"
join (my lis)
chcy
Corditionul ont) stuie - Conditionyl (ontio Stute
lments qxe Executes fustea ments L·e Execute sleue
olpi upple bunqny, Che xy
|Moxe me Msy XqujaemEnd
(5) Replace c)
The fa epluccs
subsriny with other Pregxm mmed not be Canple -Evexy hime highex level ptga
time
Ex z l o , woxli!"
my staihy
point (my stxy xeplucc Cworl" univg etr displayd afea
Fzoyxum is checled tor every imsiyu ction
olpi Hello, miverse
-

K) (ont c) C (omplex BASIC


-)_ThËs fu (onts the nym be of DCYxe nG
of u substaimy in a stziy
my-stsiny Hell, wodyl Hello ayais!
poini Cmy. stiny. Covhi ("Hello))
o<P:- 2
Date
Pugd elassnate
Date
Page

chey
(: "pplc,s pbangn4,
X my - [tsinyny- stihy lhC.") Diff between (ompilex 4
[ ' a f p l eb
' anqr'cheny7 Com fileX Intex Pxetex

-compilax tukes entixe -Intexpiehex takes S))


K4 Join )
The fu (6nutensts
q list of stxiy input jnstucfien us nput

Imto Tntex mediat obiect Code - No Intx med)He obJect

ba rghy" che ryy yenexated Code is gehcyuted.


["apple,
my -ist
onditionel cont Stuie - (ond itionyl (ontio Styte
lments 8e Executes fuste ments
olP pple bungne, Che y
More me maay Xqu)Bemeni Mmoxy XeguizemEnt is
(5) Replace c) less
he xepluccs OCV yencs

substxiny uith othex -fvexy time hightx leVel prg


evexy
my staI nyzHelo, wol!
foimt (my stxiby Xepluce CWory,"uhiIsS) E355t displayd aftea
entixe soyrm is checked tor every imstyU ction
Hello, DiverSe
-xi
fu BASIC
-)_ThËs omts the nym be of oCYYYe nG
Stainy
N my stiny Hella, wos Hello qyai,!
prini (my- string. (ovht ("Helle)
olP'- 2
classmate
Date
Page

Progxyn
thut
she
(oUt mumbx of
Develep of the cha xctes he qive L15t byilt -in- data tyges oi Athan
OCUXnCeS

0mput CCtex Python Psovides Sexvul built- ih- d aty


mput stxiny : that help to menipulyie daty
int flaqt, (omplex
foy Cha in
chuz in (hyaut
Sequence Types Stx list typle
if
Chux mapplny dict
else
Chus- (ount [chuz]: J Set typESi So, f7s20 set
Pxint Chyxucte3
chax (oynt in chux. (oynt. items
None Re Poesenis the abseat of value
with nsne

Entex u Stainy: helle


chu xuctex
h':I S H ello Worla"

t =(45,6) # typle
:2 6":23#dic
# bool
Datea
Paa cAsSMate
Date
Page.

thut CoUnts
chaxctea
the
mumlex
n the gives
of the stiin LI5t bilt in data typs Aython
Python
Python Bsavides. built- in- daty ty Pes
th¡t help to manipula1e daty
Numexi< Tyes intfbct, (omplex
fox Chaz in npu Stiny |Sequehce Types i Sta list, typle
chuz in Chyx oUni

else
Chus (ont [chuz]:I
Set typesi
Paint (Chyxuctes ") Boole4n Iyfé ! bool.
(oynt n chur. ([Link]
fin+ (f Lchaz': o ) None Re Poesenis the abset of - vylse

Stainy: hello wer Ylo


chaxuctex
S*Hello Woxla'st

- ( 4,5,) # tuple
# bool

+
Date
Paga
classmate
Date
Page
Q55oc)ated with us
out methas
QueE List Ex
theiz clemek
Lists ql]ow yol to chumyc
initializatbh.
they 4r
ytufk : ( ' A t " 4)
314)
ove item afte
m
mutalle
(ouecti of tems thut (son
Iists Mutable ordexed callectian of items
be chunged -
Cyn be modifies.
- Define d bxackets
(emmah hetheds Camontuin mixed datq yPes
JPPend (x) AdJS
tems fxom lis =Clo°3]
extend Citeoable)_Alds qlL my- lis uppen) (4)
jtexable to the e
mdex i
XemoVe ( ) ’ Remsves fixst Pami (mylist)
3) Dictonuxiesi
So8+ () Sorts the list
he list
Mutette (ollection of iey-vqlue
with
Ruixs.
exumple
)ypplei:
inmytuble, oxdeoed tollec tlo of items. my-dici City"]P4zis"
Cyn't he molifie Pximt ([Link])
Defined usihy () Putrn theses
- (unLontqin
duk tyP
Pogs
classmate
Date
Page
Sicny opCsqhion
Pxactice
the list yngye. woxds Set (wDTd S)
element VIq 1ndcX
’Acess for woxds
(staat Stop
- s5e Siciny
occynces
Ex 30, 4o, so]
15t = [|o, 20, Qle Di[cuss fouk built. in dictisruay with x
Brini (15 +_[1: 4)) ValuesC) Retyn allkey
Values
Yea) 4 file tet
Dkvelap 4 Brogzum to get Ckey defuH)
de fquH): Retum
filt 4 do follsuiny
H key hst found
4. Pin no. o ines |) dict. key c
b. Pojn no. ot nge Woxds
C. StoY¬ yh wor with it's o((UXeh m My Jict =("nm Bol"
Jidisng Ky my dict keysc)
Pzim t Ci st Cke YS))
file nme Smple. tct"
with oPeh (filenan, "") 45 fik: Output:C"n4me"
lins : filt. Xeudlins ()
2) dict. alyes
|L
fox line jm lines: my dict :'suc':Luf top"ic
wo~)s. extend Cine5taip ). 5plit 0)
Print (Cis (vyls))
DaTe
clAsSMAte
Date
Page
CKey-dcfavlt):
3) get
Cnme') tay Code bleck wheoe
Cny. did ged
(my
bint ([Link]. ge Ccit eXept Code block to handle the exCe ption
Pint excep tion
finallh code thyt XUns no ma ttea whc
Vnkhown
lustxute mutabiliy with Xespd to ists
ty
theix lemes hym : mt Cinput Chtea
Lists uxc mutyble, Mqnhy atish
bechangtd aftex
except
n (unt divik tay by 2e")
Ist C1]:5
Print (1st) #tIs3)
Q-12 SUm hundl'ny Pximt ReSUH
It is s mechanism to himdle xUntime oxs i
of the finahyPaintCuecutloh (ompkt "y
Pdoy4m
Eyors detected duziny ecution is Called eacetpt Sul dusseS mplement the abstauc methods_af the s
Isn exe ptlon hanalny. you can cath
the Prayra mfrom (74shiny abe imp31 ABC 4bstact ne thel
Pog
dassmate
Date
Page

duss c48 CAB]


abstuct me tha
algoithin
def binury
bingn Seuzch (1st,x)
class MqNuti (c): |ow, high: 0, len (15t)
def staxt (selfJ while olw (: high
(MAruHi Staxts ") (lolw thgh) l2
prini jf
cgss elif Ist [mis]k
def Styx Geif)'
frins "SQmtys Stqrs")

high = mi-1
m= mqzuti )
# ole Mqxuti starts
m. Sturt )

#olf ->S4nbyo Sarts Paini CBinaxy Sexh (15t s))


#P
Exception

tet cam he hynle ô6 wite q fogxam to /mplemeni to uick[oat


flqpithm
(omplled tme o BUn time def Qick sox (15t) :
len (15+t)( 1
- &: ile Not foUd
Sys tem (rot Pi yot= 15t C°]

ysually hot hundled -(un le


classmate
Date

Page
X(E PVat]
Piva)
CPivot] guict Condude
Cless)
94ick so2t
(yoeatea) Stads:
- follows tIfo Cl4st în fixst oUt)
main Opexutisn ush Pp

# olP Stack =C
Stuck. yppend Cb) # Push
Suck 4ppend (2)

lqboxutc the ussge of thcs m Pytho t


QUeue
engble mylh-
Thxeeds in Pyhn tolaws FIFo CEist In fisst outl
Pexalel executien of (ode
Mqm oPogtlbn emqueye deqacue
Use ful foy Ilo- boun tasks, qthes 1h4n heqn
Collectionmpot degue
CPU omputution

Jolm c) to wan fo jt.


is-Glive to check if
qyeue. 4ppend (e)
4yee. PoPleft () # de 9yeVe Crem aVeS 1)
Advan tages
show
Mykes Ptsgxems tastex 4
Suituble for handling backgroU?d mpoyt tuxte
htes fuce
Poaumming tustle. Iuztte )
clussate
Date
Page

wite aytm to mpleneht Lot IN service


t forwyyd (loo) with MysaL databuse
t Jl_ht (9)
#Estublsh Connection
t. Penyp ) host lolalhost
t. goto (200.o) Youx - my 5 - use"
t. Pendolwn O fasswoxd : "Youx Pusswod
databa e
db. Cuxsog C)
t fozwyd (lo)

fusswozd npt ("Enter Pysswora!)

L # out Put uery=stecT* FRom

fin oym Succs sfyl ")


else:
(59U400) Poi nvali!

db. close C)
classHate
decoyeibn.
Date

(nd Page

Q-2l
Connect
Example
5uitublC
(toxt shH}

ntes the plaintext nes5Lye Hi AKShal


i nt e x t : :
for chaz
ntex the Shif valu :?
Encaypier KL
266s) Drgpted Hi AkZhyt.
elif cha. )s owes ):
Chx (Coxd ccha 914shft).
261 9)
elsei
Yeyyn XeSult

def deayp Ciphey ShiH):


tum enCciphco, - Shift)
Puin: inpH Cnte the Plaintest me SHYe:")
Shift : im (inpH cEnt th shitt value")

Pin CEnyptd:"cihca)
decxyptd : (ryp Cciphtz, Shit)
Pxib+ CDeaypled: Jeaypted)

You might also like