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

Python Ass2

The document discusses various methods and concepts related to lists and tuples in Python, highlighting their differences, mutability, and usage. It explains operations such as appending, inserting, and removing elements, along with the implications of using shallow and deep copies. Additionally, it covers the significance of tuples in Python programming and their advantages in terms of immutability and performance.

Uploaded by

gokul s
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)
26 views13 pages

Python Ass2

The document discusses various methods and concepts related to lists and tuples in Python, highlighting their differences, mutability, and usage. It explains operations such as appending, inserting, and removing elements, along with the implications of using shallow and deep copies. Additionally, it covers the significance of tuples in Python programming and their advantages in terms of immutability and performance.

Uploaded by

gokul s
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

Parl - A

ie apRnd) estend ) mehods


Lxplain the difoene behwn
yhon tesl

Apperd () xdlds ingle limen to the erd of he lit

my.liu . opped (u)

an ilerle
{olonl ): Ndlds musluple omends from
the

to: mylI,2,3]

2 Suppeleyou have a lit o mbers,mbes -L3,7,2,8/H,5) (eete


a preyn thet penfon he folowiny opouti ors,
APPend he nnben lo to the end he l

}he
he lisd in cseneiny orlen
Rasense the lgt

unbes 3.7, 2,8 r46

) nunbns appand lio)


insert l2.1)
) numbers

) nunbens . s e )
pluin(h3.
e
liet
Setwns RroteleDersibe fourd, it Semeve

an
and The
lounple the
he The
rerneeBlurehes
:
olement PoP) esunple.Ppose emo)
semer()'()
mnemove
ethed
(mys)
Print my
lid awcoene
Pal-plenant)
paint l
pOPPRdelemond Tythen
methedin
emere 3)
l L, melhod
2
PeP 3, n n
()' Pythen
= 5.3 Speifies python
melhol outL.3,4
pud: 6] kpeufed
my emares
lits elnent he Kist
ut:3 et it
n elenen
tue in ?
value Gi
pPl2) pyhon is Ve
use an
inclezno
from osmpla
ialk
tehea
i uples nd hew it clilfon
7.¿aplain the Concept oh inmtailly
frm licls.
In Tuplos, imutebily mens yeu lan'! Chunye he

lemts aflen Greairy Jbe duple- Lis, on he olher hend alla


emeve clonmene alor Geoti on Tupls
you
te Cun honge

you hgw mury imes are


The

the Rene n both. Hewev,


in tuple

duplos cn't clage aler Geion, s0 thei


halg lany rau chenges

cheny thaln Kangh Vouy

4 Eplin the medeni of lhe uple ineiny ad liiny jn


Pytitn, higligtiny he tignibi lenee and difoene. prorib
operutios anl thein ewlomes
(nise clemgrttiny beth
Tuple irlziny olou
sliing
a tuple Posilon, Stoti ng from inle o
to
Bublet e6 a ple y kepcrsig
erubls you
esenticl

aeding and maniplating bgle clerne cliently


menipllating
bocanpl:
ouputi3

(23,a)
Dython l s and Pnoice an
5. Desribe the lie (o' mel hod in

fslenpl
not a

In Pyhon ,
buetign ed do Gmete a sle obew, uil
a
Buill n
a lt. The lie
Subket
Poon of he Reyuene
te ettrut
be
notction
sliny
my. lt L, 2, 3, u, 5. 6r 7, 8,4,1o]
my slice : slice (2,t)
Siub gel my t [mysba
Phind (swbget)

Phen en
b Eaplin lhe disforene belucen bples and lits in
woulel use tuples ineeud uta
mutabilty ples Cunnst
ales Creion, le
Lit Ccn be chnyel

ey'se
2 Syrda
Poent heses

Tuples ane gnevaly kasten cnd mgre memy- ehgiien


due to Ahesn inmabily.
Condain
ost Conp nehenton in Pylhon too Glten
We Cen use
Contosn Conlslios by
from
if atalomed widh jn Cemprehenti as.
Cn
dnelling

numbons LI2,3,4,5,6,7, 8,4,10]

nnbons)

cutpw: [b7, 8,a,10J

the dlret metheds Lo lone a

melha Pneice
Pseice coele
the awartye al cisavantaes
o uh mehhal.
domenstnutirg cloning Precess
eunple
meth to clone
There re
asntayes and disnlag.

USing the lopyD' melhol:

This met hol Geutes shellow Cory


louute oß he it, b the
he dop - leel

elements lhansehes ane ngd eud le) (opied . meuving chenyes


lo netel Cbyels uill be neflelal both Hae eiginl

cd Coriel
Pregum Criginad iu

Nlventoyt Simyle ard ConUse

Diaodund aqgf Shullew (ery chryes bo neled obyew c not


Aelatl

This mnethod Gretes a hellow Copy o e liw by


Bu. i has siiln behaig lo he

Progum Origind es :[, 2.5]

cndage: Aleo imple cnd Conite


A
Dialnaye Shullow Cony Chuss o nceul ogels are
not ieslutes.
3 Uiny t h e u()' Cons nud;
This mehod (Netes

(einy hew wih


the

Aentoye! simple Gn Commonly uel


Dilsuertuy; Shellod Cory, Chenges to
Dilodvedy lo nesal olyedy
module:
4 Uing (ors dacpopy()' rm the 'opy'
This mehd Grede
as wel).
Vely copiS all nevad obee L ress sn a

(ogied- list (opy- doap (opy(oigrl i)


Adrntaye : Deep CoPI:

(hnges Lo noded olyts


are

Dibadandaye, Reyi03 (oPy'mole, Can be


Aloses and Conme mone mensy hon leoye
nesled ils.

Concept a Genande ecp esier An Pyhon anl hew


2. Eaplein the
eleiuerd Poesing
oth
Cenile wy to
Python, gened o
ecpreeion
In
generales Values as
genends t

ane Bimilun to liet


neeles. Ghenerto
all Hae gented Volues
tey con'!
Connprelni ons,
hey yiele Volues ene ot
at ene. Trtead.

ine, muriny
duta Res.
enclosed win Parnt hegis
jlenule
bypi caly

pndnies keauene

to genede baunes

Velues
n

Psint(yalu
This Cgde Cheules
4)): wich gerorule
| bo 5 The

oyeu oand Prints Ryuurel Volue

a Pyhon Progern gel a lu, sontel in ineingy


Orn by the lat elenende Duh duple Borm a g ven
tupley

Usiny the
Cust om kontirg ey iny

tuyle
tocemple

leunle , jeey - lumbeu

-meln"
iml

Prin Sonted le:", Sodel u)


debi nes a Bndom' so
debines be. lustlemen D
Thie proyum
dmput. Lreide the
thwt

fpuneion, Hhe i

lat elemen buple The


boel the

Penel lenbcu funts on thet


Jey'
the
9etnel
Sortiny. nally the

Sontad is: C?), 3.2), (i.3), (5. 4)]

tee Qevntyes of uing duple ahignmanls tn


Python Pani Culary jn enies i n l y mlliple
Vaial Prohle detaj led escanole due dny the
useblnes dupis awiny a

astigring Veles.
Valss
Actyes
x Conisen8

sehulnes of tuple asimas n


Iuuting the
Vales
and asing ny

b=20

Pitl Behore Supriy:")


Prila: ",a)

a, b= b,a
Spp)ng: ?)

print a =")

bupde wignmed allous Ao Swep

the Valus Vari lols

Ce, wihut the need Bon a kempgy Vani alle. T e

Coule eodatily and dues fhe chenes


Eoteumple

-mun

turlu. d : [o.s), (3,2), (2.), (s.u)]

This proyown debires a


debins fundon so by. atlenen
imput Inide the
tht

funsien, he

last clament buple The


bousel the

Pornele leunbe furutson ret


Jey'
the

Sotiny. the

Ouput

4 aplain e aewwntyes o{ uing duple akigns in


in enanie inl mulliple
Pati Culanly
Pthon

ViallPraile dot j led escenle duvtiny the


skigrind wng au

asigiry Vales.
rumpt ?
Unpny eun values ob a fnwion winy tupl
cley gel (oeirutesl:
elun 10,20
Uing Valuts tiny upe ascisnmed

,y- gel Coonirudesl)

)
Priny. (oobiae;")

the melhod on aesny elemens ish in a neetel


tuple PYhon? Preicle oample illnting how to
etneue Speuti Valus tuple stthe.
Brom nuted
AcLesing eemenl! w n a noted tugle
Pyen inle iny mulliple indlainy
raigle thogngl Hhe
cletire elemen inell doooeponeny
to a the teple
within

naked. Luph(ty ), (u.s6) : (.3,))


Value
neskal uple L] aese e seond ule wtlt
te oent
He kupls,

index thet dunle,


heing ebieed

nestal teple =(i2.3), (4,6, 6); (7))

You might also like