0 ratings 0% found this document useful (0 votes) 10 views 14 pages Avd Python Unit - 1
The document appears to be a fragmented text discussing various programming concepts in Python, including lists, sets, tuples, and dictionaries. It covers operations such as concatenation, accessing elements, and modifying data structures, along with examples of their usage. Additionally, it mentions the immutability of tuples and the mutable nature of lists, highlighting their differences.
AI-enhanced title and description
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
shades 7 1m
operation fh pie |
:
4 :
(SA bteat
| ek ALY)Sas { Seas te
4 2 ‘oa sti pytren_i a sequence of chaning
satin Bosh Pane 9, -doube ee 2) oe
| acipie CO - se ———-
hl east e wtp tne be changed, alter cxeahiatn,
coten atfon, Ye petition,”
SL _strin
He tle’
Z*E Welcome to. python”!
etd {6
erst (Sa (Ita)
I # Concatenaton
i | print (Si +7 "4 S27) Bette Python
Fe _tepettifon
Z [ prt (52* 5) tyson Python Py nen
Pim el zol itore
[| c Rregey , stetngs 6
+ _Lfsts exe mutable —> eter enis ane. added i
Cramale = wine __ removed» 0% modi thed .
|| Creat Fn A fse
my cifer © flo, 20, 20, Python", Set]
% | Accessing elemerts = le
fist (my— tise £0) to =~ as
et moe it tm) * mer {te
% | updating eremend
; silos
a ee
7
# | Rading elemerda
my, it. append (so) |
ae HCG, pent, BT (
wmoving ete 7
H) Re gene —E
mg- list evemove (30)
| Bete CGT P87 9S BHO RV GSB)
loses of Lists ' =
io * | Store and: man z an : =
“28s ful to _Pterating , sorting, se man ty
nifdely used fn _sata analysis , mactint (ean nity) 4s}
and we mes bs(oa
ot allowed fn as
ges _bt_crceated osfag Uh ar ss set ;
2 LAT poy strane 4
Ie = Jem x 4
o~ 8 f2.8,31,1,44)> 0
— seta-s 18,5, 314, $. SF
—l Peers
*
em av iin welt vol Peat
cha te menberselp - tecting (enecking fh an
= [trem exists).
l
1 Creakfing, 9 Se+
J | K Empty set
gi = Set O
| HK don = Empty Set
: SES HTB, 3 SE
2 SOS SEE CE 50 307 FT)
—#F—L
Prink (SZ) Roe ass
I
Indlextn g —_arol” SLichegy_= 45 -
Ta] petete bteme yt$ $<
_ ss gio, 20) 80) 40}
ia ere (28) Hi Remaven _Speciefe etemeda ro
a reset) 6 e
4 Cevrer_ fk not _ pres! £
fs H Remover Specfete element Ge
$+ alfs cand (50) sae
S. popPD # Remove a vanclom clemect
gS. cleay() HK Removes oh eee (EP) K
Set: Operaotfon
(0) bnfon (1 or _vonfon > Alt onfgve element -from
I both sets!
Sea Le, 4e
[B= W345
Levit (AB) #* £1,2,3, 4, 5F
[pelt (R. vnfon (8) #* {123,45}
|
Tr
[ 2 yl
| Intersect fon (for intersection) common elements ony
4 |_prft (os 8) % it RoE
E, EL prt (A hitersectfon (ay) fap CU{ou
{=08 atsnnce)_ 6 Elements th A but
not ta
pea i een aolifference)—»
% en bsy
ee ans)
—~ ES (ee sgrnetatc a eoee (8) mw -Si.2, 4 SF :
ry ee ote stertans
mAs
% Length > 3
en lS
— pal ‘ath S) RW Membership test = Tree
pre (re notin J MMemoestlp test Tse
LC % COPS
_ sre RY * 3
menses = £0, 0.3. 654% 57
unigue—nombers= Set (nom bes)
= pret [onigenombew_y HOTT I, SF
! Perform motnemadical sot .cperntionA (wrfon_, jWersection, ei). a(t
1 Nem bemstlp testing. -» checkhg Jf an tem enishs I vetuple 2 (10,20, 35, gython” 2.14)
_prist Leng teble)_ ~
, aes Moy nia |
|petfnfifan of Immutable c [enone
| mmudable _meand un changeablé ___ ie
an_b. xeateel by placihg ttems sepqrated |
{ Stonting, {rer 0. a
| le can access elem he ah
yy He [a ey? 7)
=
“aii. a ~ prtt (Hay —~]
by commas. unsiale parentheses (J —} fab
T 1 J
Example | H Creatine tuple pe
| tuple = (10, 90,30, Python")
| ee pul (ny. type) =
M {12,20, 90, python") |
; |b
i
$
s 1
1.3} Aece ing —Torple __ Flemeids
t Eoch_elemest Po a tuple har an _'oley num bo ett
|
}oN) ahtvatting ower topte
‘ . pie ean —uS*A_for Boop to go though }
wee? frat rn 3 = ae OL theme voy
—T Colors = (req? green, “bive!) 7
aa ake teers
Tota etna aang a pe
fing tht tne '2 NI at —
I) Ss ‘ Se oe pee eae
a = noms = (t0, 20, 30, 4, so)
| ped [nome [1247 ) % [80,30 40)
TT (noms Ti 33) % (states
T Prk Crows T rr2 7) % Ue, 90, 50
=e
wale
|
4
+ |Tuple ore Tenenuctable
= ' ;
i eattal me eannet “change
~ Once & staple f
| fis - ele mo vst
[sper 5 X_WS wil) give aw:
o)p TypeGrror_: ‘tuple’ abject loos nat > support
¥ Prem ans tynmect
MORE sia CD
(Hi) * 3 Cai), ewF, ear)
(4) neces and _ element
element L
133)“Len((t 2,3,4))
TnL) Reforms tha tangent elemed POX (CE, 1 al °
a
crepe tere eta
: 4 eforny Ha Smalles Mom i hoses
Pople |
_— mor alt omar 7)
som() re "Secrest 2
ie
Clemerda pres
Sop
Retorns-a-$0 d a pas
4upl ra fin ol +1 Ei
fase ceatlpt I
ie) t
tuple core ante RELLY CRD afc
[__ Ciike list 1 strug or seb) |
1 ios oF Uple~
Scecthts vel
Ha
2+ Rede (veuloe) pos_txample+ student =f
“name "2 Abhay“)
ze Havrey "1
age" t a0,
* branch"; “ C6E”
keya fvaive 1,
Wey 2 evaloe B
in a
sl ae ea
Studer = Afet (nome =Sqvare__ Br
spent Epes
: Abhay te
erarreat ni enisk —> Key free. Tp
|| st get [) Nediod
ST Adding ‘Ttews
| sudo EH roll
yo |__ Pe (stedert)
TPT Timame Tt Alvhay "Page: 30, elle TOTE
valor ¢
StodetT Mage") = 20
| a eat
Frames Tapas’, Fogel: 217 WULKe TT Te: femouirg Trem
. ____pesextphiom 4 a
“penover fem wlth specie key __Studand» pop (“tage
moves lars furexted em _stndenk. pop ftem()
peed fem or entive afet del -studet [“name"J
Srodewts clear ()
4 Kaynay.n, Hage’! to
Mage")
_ eae
rier rapnoy’ + © touwne’ “CSET
rt
4, sagen sb etn
a EC UEPIUE SE
i ane ki Ay EEETTE mea uchable aft Xa st
Ips numb 2, tople)
(we sae Wrlame” and “name “ave names a) thames oF
| Aires t i F]
Malueh (eam Values Can be same Qi tio th't pp fw
Yoo
z Brg data = 1: “one
pred (ala £23)
ey 12
Ruflt - fr Oictionars,
tue! 75) “HF three SE
fame! fnbhay’)
_f awhay?key -valve_polyt
(oa
—type(atel) —__Refurm tht yet 7, Tolteh! >
fats) in tans “Sp as
String — conte
a
Trevate thro
ology , or hath.
go ky
+
jent = { “name” : Hanoy"
Mage” + po
ritng
‘branch V2 “es. FL
op Preah Rey?
) in Sfodentt
rest try)
Tpviet Calve).
PH value):
isp pereagh both ey end valve
peokcl Ley
Lu] ateoted ni
A_soltcHlongry fnstde an adher
a nested « hho axycared Fine oi
a Cent ae EP TD)
eS
yp Senha ard
Coeet telborm eH
vsed fh APTY and web
ane vote
——_] coat _Cowt occurrences of ol_Prequency he
een aa Trend ee eel
tr i ¥
“py fe poratin Stowe seningn mappings Key-valve Sefiihg ete
__& fommasy—Table_—_—_— > =
= Feodone péscriphion
Tel dictionary,
ot teaate Yes
— Attire fos (typo
lbote KeyA wet plowed
te valves Allowed
By key
t
f
site Ley 4_vetve
Litedne” 4 # Abhay, Hage” t2eh