Data Structure in Python Language
Data Structure in Python Language
By:pythan.huh
DGer-defined
Built-in data.
Gtructues dartr uctures
my-isteL2,3,erampleA.132,10,30J
del mu-list ld# delete elemestat nder 5_
pn Cyis-
A myispop CEpp element fhm list
pånCoppecd Eiemeria
my list.clear) Ëenpty tho ist
prn (my list-
pythanhuh
output Li2,3,erample, 3132,30a
Li2,3, 3.132, 3a
PappedElemert2
erumple
3132
30
2,3, ecamplea.182,1a,30
examplee
Creatmq a uple -
yau an crecte a uple usinq puuenthe
-6is oc using the tupel)-function
Emy-tuple CL2,3)
prio(my-upie -
olp Cl,2,3)
Bresinq elements
Accessinq elem ets is the same aS
is for accessing values io listS
alp
2
Tuolo LAPIItho
Python- @python.hub
La,3pyahan
L4,3,Rython
app.onding lemets
TDappend +Hewdlues,-yauuse +
perator ulhich will takQ aotber lple:to bee
appended to itt.
my-tuple sC,2,)
my-tuple = ns-tuple+(446 )Facdo element
prin-my-tupiejH
autpu
CI,2,3,44T
@python bub
sets are she allecian d unetlered eiemehts
that are unique It He sdata is epeatod
mre thah one ime, t cuduld be endered.
into tne set aml Once
Creatinq q teti
sets ae created usinq unsbacess-
but înstead okaclding ey ualue psicsucujust
pasS values to it
my-set-+L4,3,4,,3,2,5Creae setE
prin(my set
AddngelementS =
Toaddelements,you use theacdd
unctton and_eass tne vulu io it
my-set 2142,31-
my-setadd add element ta set
prîn= (my-set-
alp L4,3,4-
Operations in setsi-
Tne differen aparationS on Set
Such as unim, intesectico ancd so cm ae
Shawnbela
my-set=i, a3,4
my set-2= 3 4 S -
pan+my-SeEuniom my-set-2)
pin my-Set ntersectimCmy-ot-2)
prin(my-set cdiHerence cmy-set-2)-
pin-ny-sotSymm?tnc-dif-Cmy-set-a-
mu-set. c l e a r (
prin (hny-set-
Onlon ()fumction comblnos darta preseDt M_
bath sets.
inaersection ()Hunctian finds dat prtient o
bath sets
difereacec)unction deletEG clata present
both and autpurts_data pesent enly in set
smmetic difkrehce ()functidn da@s sam2ap
diteen.ce nction but ouputr dataunrb is
emaining o both sets
Ouput
L2,3,4S6G-
Sets-2 @pttton.hub
Dictionar- @python.hub
Dictionanes ane used to store key-ualue pairs-
Key vlue pci is ikophone Dumbers uith
otuct name impllet's understunclmaei
ceatinga Dictianary iE
D create clicfinan we use. curly brae
or use dict functian.
my-dic+:j#empts-diticnary
priint (my-dict
my-dict i pytbon'a: Tava'E elements{
prin my-di
olp hon2 guva-
Deetmq Key Vdle pais
D deete ualues,use Pop ()unctin
unicb_eturnS Ndlue pnat has been cdeleted
Accessinq Elements i=
Nou n_access elemeniS usinq -
keyscoly You caneither use g0+U nction
d JusSE pusS h e s y values aocl yauuill be
etieinq the Nelues-