Download as pdf
Download as pdf
You are on page 1of 13
AECTURE- 5 ©4-11- 2020 ‘ @ BANDV BANSAL Oe ee aes le TE fs a sequence G characters Ly Use Index to acces chaxcckon ip a ating be Tp woe Hey Po ‘access Endix euk oF xarnge ot wue decimal Ouro bed se 10tll get aD Bese » Ly Supports 4reth +ve & - ve Irclex- & there ove TMetabte. ly Elements cee enw E hax been anskgnedl: MMe car stroply suassten clfecent stings OIE: SoS 7 Suppers Enoletng as tell as altefog, dist Propuctics : % Ik th a sequence detach hee fr Used 20 store aotlerkion ef thers le Orcler is pswosewed fn a List fag) by Mutable - oS bs Indexing and Slicing axe supported . le Bynancte fee) trowore Ge decrease én 4b Turphes Pecopecttes: Ly Similar to Lt but Inmroutabte &lh ba aqune data type ly Supports Indextog and slicing: Set Propecia: by Umerdvud collection ef items Tre -p therg cant be indexed Ly No duplicates are atlewecl. be Mutatte - ly Used to peferm mathematical epexation 4té%e unten, fnteuetéen oc Dictéonasey PRocopercktes : ly Oneiclowd cottectéen of terns fer cant be Enclexed. Ly @thee compeund data types Hove enly void = as an element where at a dicttenasy Aas Q BEY: VALE paise- : be Ker avee sentqur, values roa net be auntqre: ‘values can te of cuny Agpe drut Keege mais be. frorautobte DECISION- CONTROL- STATEMENTS * Indentatton : > Papthen swlter ep Endentatéon (chttespaces ot B , 8a tole apace the Beginkog of a tine) to define seope in the code: IF: the ay condttien is consfolerxed, whe simplest ef she three and mabe a Olectston Jraxed! Jeon whether the condition. & Tsu oc het LAf the condition is Huse, H psint out the tntended eapsensst6n- Wp the conclttien tk false, H skips Pscinting the Intended axprenten. *ifp — a=l0 b= 10 Bte—=b)- “ px€nt ( ‘yes’, a-=b) Point UHI Pott (' welcomed Bent (“ence O}p = ‘Yes aa=b «Hag, t > Welcome “exte. lp — num = None iS (Dum): ~ Psiot ('nuumber is pesttive!) Poh (This tre wit prtiat aboay) Op - This Line wet pedint alias. Note : ‘o’, NONE —> FALSE # ip - nun = -J ) €$ (num > = 0d? Poeént (‘Number is postive) ebe : Pseint ('Nurebes £2 negative) Foint (this Une wttt pecint aleoacge' Olp - Nerobee £ cates This Utne wr psiint akwoarys IF-EASE: the Eh ead Atatemint evaluates teat expreasten and rit execute the beoly ff Only when the text condttfen fr Tou: TY the condition isFabe’ the booty Of ‘else’ ds executed. EUF Ty the previeus conditterx wou net ture, then this conditien Ls zed). * Vp —- nun=0 &(nunn7 0): Point ('pesttive!) elf$ (mum ==0): & pdine( Xow d else: Psnt Unegestive’) op = Leo). [Pp — nun = 20 (num 70): Poctnt ('‘pesttive!? at (num <=0): Beant (‘xer0) ebsec€ Podink Cnegattve!) Olp — positive * Up BS nti 1U &£ (num 7 07: Pecint (' postive’) elth(nuum> = 0D: Pedint ('xex0? elses Pottint C' negative) lp ~ Negattve- NESTED IF -ERSE: ee) here there t6 an UY Astatenrent (ero % -2ikeed Ef - i} - alse) ds pent ingdle ansthue i ' statement (eo Sf - ele 0 Y-- elee) then, Sk dbis 4s caused as vesting 4 conte! shoterrents * Up = num=so ig mums = 0: T$ (pum = = oe Pein (‘Zere) eke + Portnt (‘posttéve') ele: Reetnt (‘negative olp — exo WHILE LOOP: poe can execute a ret & statements as tong as a conditteo is Hare. Count = Oo 2) th£te (count <3): ‘ Pend (she count a: *, courst) Count = count +4 PSOE (" Gowd) bye! count iss |, count) The tent Ga aa Yhe count f2 21 Tear Oeisripe eee o: Good bye! count 6: 3 tup = C1,2,3,4,5) Prod = } index = © while (index < ler (tupy): Pecool ® = top [index] Yirndlex + = 4 Podint ('prodsect = $3 , Index= £3: Soxmat (precl, foclex)) Ofp - psaduct = 120, Index = 5 Pood. Irclex. <5 1 ot a a a 2425 6 = o5 4 Fas Sols AIHILE- ELSE ¢ We can sun a block ef Coole ence when the Conditten £2 ne Longer dis daw * Vp - tup = (2, 3, 415) Prod = 1 fndex = 0 rohtle (Endex < en(tupy: Pred® = tupléndex} Endex + = 4 elae + Pstént ('INo mete nunobevct én tuple!) Poeinit ('pocodeect = 2 oe Somat (pred) Olp — No mee nurbexs fn tuple Povocluck = 120: MEMBERSHIP OPERATORS: sed to f€nd thethee a value et vardiatte fs found fo a sequeerne: “fo and net to ane the membeuhtp eperateu. lrLe werk: on Seks and dickéon avy. fo: Retesens Hue a ee ey specified value Vis foesent in the ebipect- net tO: Retoens true Ya sequente withthe © a Apecttied value Le net present in the object: Lt i0 Ler sequuene data Atuictusee v Mat [string [tuple] Range - Let = 1 B4J [p= it 23 OF eae Pent (5 £0 lust) Yp ~ Lt = [t, 2, aj Olp - Toure - Pstnt (2 to Lt) atct-frz'a’, 2: 'bt ofp - False. Petink ('a!' fn dict ) ick =F) sta, >: Psi t( 1! Ln cect) Ip - s= 'Weleorme' apa ' Pseénd ('0? Lo dict) FOR OOP : Dyer Lp Js ued Jor Lttecating oveca Aequanxs. (that Ls ditboe a Lat /tuple/ set/ seo fee #\ fp - tup (10, 20, 30,40) tow x to tup. Psk€nt (x) Psint (' Ftefab) Op - 10 20 30 yo Finks. RANGE : Tk sukwu% a sequence of numbec, starting fesm ‘ol by default and tncem- “TB dey 4 (by default), and ateps Bie >) SYNTAX: C8tactt, stop, step) eu Staxt : Opttona), An tare number Serta a oe Atooct - Ofault is ©: Stop + Requtsed, An ere neembere Me he at which pestiten to Atop (net included). Step ; Opttoncl, An toe neernoer« cehie| the inccumentatten: Bgautt is a Ip - Sor count tp range Ct,t0, 252 Pediat ("the count in: >, count) xp ~ Sor count to seange (1,92): & Point ('the count Ls : ', count? Psefnt ("good") olp - the Coulee ine the count ts 23 yhe count + whe count iF Good

You might also like