0% found this document useful (0 votes)
53 views16 pages

Python

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
0% found this document useful (0 votes)
53 views16 pages

Python

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
You are on page 1/ 16
: —ASSTON MEN = 2 nite a THtan =. pedal thal oe Caaprarn fe Cradle, 2 Steig d- [ginty = “Hello, World £” | pdt (ste) Jecepal t= Hello, Derlel | a Write a Python Prepkan te delete a ay Prag Kam shame “Hello, dell |” puch “Ontyinall Stet 2 sheduy) del stedny J 7 7 pried , efeted Steins : ‘ shaw) Oubpstt Original Shiny? Heller, Werte! | Deleted Shey! name ‘ stretey? tt net dk [incel E 5 fay pythen Presy iam te access pte Chanactery of a hee os Poy“ te (eC Ace easing characters ashi a kept y) yarclan in § Lng? peintCchan) l lpr In fecessing specifies characters uttp fuclectugt” re US AL let shins [e7 ) J md vid (“At Pade 22”, stretup LJ) geet (™\n Accessing the chara ctites wsteg slicfiep 2”) gett (" from tude © +e 32”, shiv [0:47 ) edu (* Leon fucex 24a 58 ” shot [s :¢)) privé Chem sled te end! by jurp & characters? : Strap ltt quand C\n Accessing elaractere % anh Or 2) 2”) prcect (Reverse t i shechag [: ; -1)) Dudpr- Aecensing characers using a loop: gor bee , Accessor speeifi= clanachrs csing feolevetay | At hee 2 YP At Sndlex 24 - Recessing the characters wurny slicing? from “tuder ote as hth i sto: he Ree ESE ENE jap clade Me Reessty clenacfery In neverue pile! | Revester t nehty? | Cudsdte Pythan Peay tear te Perform cperdhiong Or Shays, eeghearn t= sar sample = sheng -" Hells, «Darl | het ya sang thing Bfergth> fen Gampk shen) i wiracwe length af “the Sheng? f Gengtt}") sista! - “Helle, : shrimp? = « World 1 | concdenated shy : Sheiyl + strip F Pak(t"2. Cancale nahi, 4 {Concefenated. shel] )) E° substring = Seniple. she fins 9] Pink: ( £"3, SIoeing SWeings { Subabring} 3) Capper case - shhsiny : Samphe shiny opel) Iswercate shige sab fe Seine. feosen Peed Cha, 9 F oF ppercase ¢ [oppercase S Stacy? *) Distt CS louse ACs? f Nousencase- stredy }) replaced — sheng - Sampk~ hong. ree lace (We, du lyn ead (fe. Bp rT pnegac saggy (1 eae) toerds - Samp ic sthcing Split. (% ‘) phn (fo. soli: fecerdf stands —cctth fells — Sample slrcng, slavche oat Celle 4 ands cath sf veiage Sa ph ship endsunil, CStheine. ¥) ped (47. Shark asith Vell) Estate eit pg, " PECL" Code echt “GHhetag,? + fendecitlh. Str index = Sampk— sheng, fad POPC ES Oden & sample) ‘} ) "samp? : fidese 2 Count = sample — $4 ( are PD Pract C3. Couet Ning. Count ( is”) of fish sf cost }*) Coalaing ecealf - “Would” ¢, Sample. olf Perk Cg int Seen te j (# "to. Conlon worlds Feed eafy | i: -— | a joss = fi Leny tk of the sdeeing t 34 oy, Concatenation t Hells | Oo! sducng Slécby 2 Corll " o i Oppencase F HEUO, OoRLD | Ty rs t> A SAMPLE STING} Lowercase the lle, wrorl | tose tq sarnple stray. s Replace Hello, Well | Tet ik modified string. Ge split ‘[*Helle, “world (“Rip "a? 49, * sompk?, ‘hei’ ] y. sheds estth Helles Tee S bade corth “shieing? Biter & Tndex of ‘sample? Oy 4. Court ef fn 8 tor Comlang “ede? de Fyguite 3 Python Pr palind ont ak fiend te check a given stein Deo Hami- a 4 i pulinelicome ( inprat. ste pay oe cess ~ Sting) t hae stray = inp Shit et 4 creed te sheetay Se tnput sto pease wero MP . iapeot CG rten a ae sotto] { ees fuptch yi) oe Re 4 -_ gee dle : the pect string is a prbinchcome .”) viel (8 Re ty ° ? Rs. ‘input Shing & raf 9 pollindhone.”) O Cre a shetnp : radar ih, ° ° the input string fa palinchheme « 1® Oden a shiny t hello Ane input Sheeing 8 nat a palindkomne » Curie ae Presyram te Count rumbr of ibanacte ns re chang. Te Ka I= en inpt = Wrpck (“Gtere a shag: ”) chanacten — Court = fenluser — input) pak + fla number of chatcactons in -Ha sheng its {character cork} ”) Oudpet :- Cuter a string : Helle, worlel | Ra number of clascactert tn te she at te ia toe Te piftte «Yon Fepriiany Fe campanen aa tos hy, eb: ham - dnd = = tee oe a stig”) sua = imped (“ lane arctan shaky 2") a Compare. — sha C shat, S12) oe i shel == sho: return Ake steclogs abe equal. ” refi © Te strdyps ane not equal,” Lop ct Onder. a she Hy name J dlocls | Pdr anollan ihn shay? varne ch Ghat Ane otitogs ark F gach: else 5 q she “Hell ja, World|” sf , 5 pain Python (ten ces yey ot fe 5 shulingh 08 ile : ey ie team te cheat ay annay & ued clernents of 4 nee “y p t Sutghame~ yy AAL my 2 Yo [toa gud Cc Elements of Her ao %) fer element fn on — Wray : print (e lerrect-) Oud ody ‘heed of ee icrey ! Py tha: the tap hagem so cradle a dit & ‘ho Ha t= nytt = [i Eee <] it CS List Contesades 9 wl? List contents : fi,, 34, c) X= sy List) x teak yo- jee Oy then Prepteam te perform operand on qQ 1 . } Pes hea 2 my - fist=[1,2,3, 4,5] pect: (%f. Acc ting clernents by tinder t ”) pit (" Rivest elements”, my Hist(o]) PEC. Lett efoments », my List [-1]) Hind (“[n2. Modifying elemostt by tacbet® tet ns Moding elemtnts ty fades 9 pabct (“Updated List: any List) hid C8 (ng. Ap ending an’ ferent? ®) ™ bist. appen (c) print (« Updated List? ”, my List) ‘Pran( \n4. Tnsenting an element: ”) ny List, rine bs) Hit (“Updated Lists”, any His . Poke Remouiy an elernenct by values :”) PT my “Opd (st? ; mye . > Paice Cine, Removing an element by indlens ”) wale ae y git mg tis | prdeh ("\n7- Pinding tte tudee cf an elertats ) Fidler ~ my List. in dese (=) : oid CO Pole of 5", fucker) pred (In 8. Sorting tha List: ) wy- Lis sort pra (seded fist: 2s my-dist) Qt (Ing. Reversing tte Sit”) my List. keverseO print C* Reversed lists "my dist) epee Oalpat 1 4. Aecessng elements by fucker: a : rest element? 1 Last element! 5 a Modifying elements by index! Upddect Wal. [12,10, al] 3. Dope ncling an element: Updated Gist [02,1045 é] 4. Ingorbing an element? Unde EY L120 014,55 J & Reroute an element by value? Updated lish [1,2,7, ie od CG. Removing an element by tnelere + ae st : ae é] 1. Rinding the tndee of a lemevgf- Tudlee of rss ¢ "ems 8. Sorting the ists swrldd th : | iC re] 4. Reversing the disk: Reversed ist: [10, 1,6, 551] , ip 4p nang’) enter (ple 2 styple ) ae “gt > faple Gin, apple Do banana) 7 i Python Prxostcarm de perform operdtins ontuple + Beggar rate = (62,3) ie suplaz C “apple”, banana’, Celern “rts Oreaiucd Wople Le? ren it Cort Role 21% tuplea) lee ty, Ie fea weer a I oer eft Bag fT Goetechd ple _ In Rope ehed faples , reeperteel_pdupl Pad CeIn Ohmerte fs wip on bites let UT) pad Berns tom fade 409m Solon, tpl 4 . Keple 23 », tuple i3}) 0 C\nlen of 4 “Teple 4 fs , den (gles) pert (Le q “Tepe a5”, Ten (4uple)) wee (ais ef i nls “banana? present nh lea?” “banana ty typ) Mi ("| Pe reat Thrcongl elemerck of ® fer: yr % elemenk 5 mtu lets f prt (element) saith = (a, &Q>) (* Ong Ruple to be deleteds”, def tupk ) Hdl f ’ ~ tuple ‘o uch 3 Origine! Tapled-? (23) “Ondptaal Gpler® Capple’ danam’, Schoay”) concabenated Maple 1(142,3, “apple's “bansne’, “elersy") eperted Repl i i 1,2,3) Cle merch at frokx 2 Sn Japlett 2 Ele meres -{kem ‘nde 4 mae A “plea: Cbanaad, hay) Length e ‘Tepkt 23 Length of Rplee as fs * banana’ preset in ‘ple e ? feu Plenty Horough elements of Maples: U a 3 Orgpinal “ple do be deleted + (ie, ‘?) Forte Tyllen Thejtam ta pofoimn eperdiod nr olickionay-| — Eee mee et o fet {Shame ‘shac he, Sag? 20, ity: Dame h' neck (“Orginal Dichronare on ated) 2 . J Ah ("[nflecessing vaduc of tage’: ve dt ‘47e') et (ye J = er Prick (\n Mad ified Dichiowary:™, dict) . dich Peccupndion] = ‘Engineas? Le print (« | |: -Voluc puk*, In Dichornary ofien add ny ane Hey ey roamoved- value = olich pop 6 teity’) | pet (In Dichinary Her amoung Scity’:” fict) PEC Remaved valuas”, temauec/—valae) pat (Wn Ps a € aq key Gn tts clicHenary 2”, ‘oye! on dd ppc C\y Herehing thicogh keys & ustuor 2”) | Yor bey, valu ‘th dict, Homs’0)! prcick Cf "fey: § valas}”) dick clear O yon Tak tadichlonsry alten cleoriuy all items , olict) Oxdpecd t- | drdinal Bictonacr: frame: Shecls?, age? 20, city": Damned? | Receasing ual of ‘ayes 2620 | Hocli[icol Dieticnasey fname! “shecle Cares a, (eit Dame’? ve an Hem cli seco hey, valores, fds eae Die onary aflen edly a nero Rey vate patti} tname?+ ‘Shacks? : ‘gear, Ceity Dame, fe ccupstin’ ta’) after be meet ‘uy of ‘name’ ‘Sharla | ages 21 'eceu sh bard by damsh (ophucer’? Gs (ap? a hey be vcke the dletonary ie MY, . cl 0 . Mevchiny Wehewuph keys ¥ values: nang, 5 wha cls Jes at - Oreupafions Crgireer eo Pidfonary ofc ch easabey — abt iftasg + {3 pe fro. 1 be aWate Pplhon Taapham te. TAlauee angle | Cin depice) by fo & Rewg an! —~ Gmport mal def calervlacte angle (siole-a, stole 6)? i, stdeig Mo ob sole b) IF Urbke a Pylon Thapar te final Suck The Jacked | a jiven number. | + Tespkam t def factorial (n): | Wp n==0 oh n==l: \ ted arn 1 else: techn nt Lactinial Oni oe WF (Speck ("Ccten a number 4e [ined He hcterinf: ) iL numcos Pret Garon: Pactondel fe nath efined for ongadi the + Numbers. ”) result = factorial Gan) print (4 Gy factorial of frum} is § FE Odo Oster a ee te find its pfeil se Ge factorial of © & 120. fegelty ') 2 Write a Python Teopram te disply Pibonaceld sexes jusing Reauufen. 2 phim :— 4 fibonacei (n): if n<=0; refivrn "Pleate enter a postive inte pex.” eli. nee: tot [o] elif na=2: a tafigen bo, i else: 4ih-serieg = fibenace’ (n-1) fib - Sous, app tnd CH _sorieg [-] 3: fib sexes [-2]) ; gotion [ih sesces um —termé= tect (pu Cater “tte number terme a tre Rhonaced senfeg: ) alt= Rbonace? Crum terme) Mid (4 fibonscel sects esith from terme} termes” resul) Output — Oe the amb, teamy for ae Prhonaced SOE 3 Cibonacet senk cath '8 terms ': Lo, S524, 5 8, 23] 4 | T ow

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy