0% found this document useful (0 votes)
12 views

python model practical..(set 4)

Python 1st semester practical program

Uploaded by

ms8861097
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
12 views

python model practical..(set 4)

Python 1st semester practical program

Uploaded by

ms8861097
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 65
(sup. cone = GE 215 | |) SUB. TITLE + PROBLEM SOMING, AND PYTHON PROGLRAMMIN 64 “8 PORATORY SEMESTER + oT SET Pe 7 HX) orite a Pyon Progam fo generate Electricity bY and Agvelop a Flow chaxt for Po game. algovithen: - step 4: gtant step 2 : wet Reo units ralno $xomn Ro user and saya ik WN A rorab\e |Step 2, compare Ke units wheiRow | ih is <60, z= , 22200 { and apply Bo agpaunt } eoheulotiong ond QINe Re Nobis ln a Neerisbla | step 4 2 Bebermine He — suvchavags Sos XBovent onits |step = : caleulote Re he ctrreity Lil by adding ARS Arawunt and Succ hong Q step 6 4 Display eo Blocks eiky, ‘n\\ Sain print etakterant step # 1. Stop Flowerant !- Read units yo Goes —_—~ 50 aaa wes GRR ent > = 6vo.50 |) mavelop a Paton pregcram to find Be Biggest of 2 Norberg Larag rested if... eke Stabements . Algor: - Step 1s Stoert Step a: Road ree pumbors: nut, Msn, AWK | step Bi Th pond te grates Ron ov eqal fb nesna: a. xh poms | 1S geeates Pon or equal to NOMAD + Bev oicploay, perms ca TRO lowest normnbath- Else : 3.2: display noma os Me Largest queer - : step 43 Elsa: a te nvr 48 areater Ran eo esqwol to nema: A. 4 + digplasy ume 94 Re Sorgest numer. b. Else + Ad 4 Display mir 3 ah ae Loorgen t awab2t PROTON dob Fird— Sorqast Crum, numa, nema): VE Garvey (> 2 nveye) + if Cnvsnts = avers)! vreburen orn) ebae . rreator ny AWA ase : ff (rum a y= ayn a): reborn nome abe » mabeern wom 3 pret s Sloat Gnpub Center Ke first Framer: “) i 7 im mama = float CGnput Centon Me second member +») noms = flat Gnpat Center Qo Vad makes | ")) hangast 2 Find. Loagest Cromi, aera nuns? Print Cae Longest nombey iS + " Jongost) ovfpak S Eatery Do Swat nembey . Ff Extex ‘he Sexand numben 2 entey We Riek nomber +o number AS 1 9.0 2. Dan integer, mn, said to cw perfect chen Me sem of all Of ie Propes Mivigexrg rf \S emal to ©. Pov TS a pertact — number | example , O28 Ave | became its propen Av sov peat and wand tsa4 AttaxtA a) A\ gow hey ve a step 1. Stank step 8 : taitiolize a vorrallo divisers ~Svrvy to 60, Step 3: xterake team 1 te ney SSPE A Ed ie. see kiatoers of 4, add + to Aigers- sur. * Seep & Altar Re Looe , check 16 Kylee gen is equal to n. step & + ot “Rox ave equal, Pen n ; ga pefeck number, } Program 3 « | dog Jg_ pangect number Cn) 4 ‘§ Neo | meaturn Falee | | AN) Soys _ gen = sem Cf gow i in vange Jond ie ny, it ee): | d retorn divisors _ prsmnker to. check = a¢ Jrowuhk = is. panteck— number Croiniere, Som can ponk ce Srornore to- check 1% 9 pestos ext tormbene t Trros ab") wud ot Le pe is & pargeck number 2 TRE b) menalop O yon — Pryor to Find whee Ko aio number 59 positive oF neqgakive wring 18 Satarnont . nlgertres step t . Stost step at Read nom cep 3.2 chock 3H numre Ren pent nurmne2t number 12 Post ke oRewwige Prvat oumber 3S negative Nwsrlosrs atep A: shop. Pron coi’) nom = wt Gnput Center we urnpen = 12 Cau 2 oo): sant Ce rikina sorber’) w bt alee + Print C negative NYPAbEx ) ae Enter Be noumbey +. 5 Pos\E\ve Horn @e Enter Reo nomex ot oe Negokive number _ a JQ) develop a paikon Program — to rod to nukes af ‘input ond sunp Me two numbers. (sing faoe — vorviclblea) . RlgordviRen > - ileus Step 4 + gtant St2P g@ = Road tose nombereg a, b S¥2P 3 tf croate a Tem poran vasclalla step At Assign Ro value o¢ a te Learnp step St Assan Re, Nalss of b to Q stsP 6 2 Assign Pe volo of ternp to ba : step Fy prinfb a, b step ¢ . Stop Peeqearn Lo a= inpak Center velos of 22") be input Center velna of &*') Print Cashore Sompping i) S1'o) temp = a a=b b= torn p . Print Castes SWAP PAN, iY 4.09 ie) output in miex ‘Re value of ars f Enter Vane of b > 8 | [Before — SWAPPING . 5,8 AFto« LAHOPPINQ , bos b)aevelop o — PYMRon — Fregwoam — +o | mod Humexator and denominator Lard Point Roir wotiont & nemnindey CS step \ + stot step 2. Read numerator and denemire ~ tov Step 8. ure Be Avieion WV) cperotos to Giod the wotient KEP A> wwe Re madolo (7) opaxator to Find he xermaindar step sv erint Bo gquetient and pea rra Lone s¥2p & L stop, nosac-rator = ‘ae Gnput Center Ro Homaralor t »)) doneminatey’ = nt Gopot Center Ho Janan\mohOr ) qactient = normoxates | denemroker Wemaiadars pemexater fo denominator Pat Ch auotiont + LwohiantZ 5 Paint CES Rermarederr * TRemmmaee}’) Bel Enter Ent av longtis I Algae - jstep ts stat Step 2* prompt Re wer to enter Re pe We nvummevahos: Ft Re Aonrominahor 2. @voblent Ramaindes = 2 Duwtke a Pram Pat aceopte Re of Reee cides of A tvargloy as Anput Anteate, WS wight txtorgle Grell From aBo Pyfagoran Bouom Bat im a wight tangle , Re Ware ef ON idea iQ he sum of Re QUanet Of [Ro oer two sider), 5 Prompt Re Vaer fo enter Re 1 ews Aho pragrarn sukpub — should wheRer os not Reo triargle \erai of Re Syst Affex Ro loop, print sums stort and gum. even Te given Yet wing g gor loop. EO gyn. QVON- Tm! Re neober 1k add, add it to gem. odd. Stop, Sum _ odd = 0 SPV. avery, =O inpod_ aurnbarg = Wa SrA Se bit .% af foe warm 10 spol — Number S + if Crom ye ae z0)4 BON — VAN & = AWN ee: Sum odd *& = AU print Coos sf odd qombe® s 2! sumed Pint (Ssoen of even TAMbs v8 2) SOM QV output Sov 08 Odd Puelore 2 ne BONA OR yor Oonbons + 2g - a) urbe o. puor Preegrcayn ty awk Re 5 taolbjurka money Ord Agplouy Reo ANG Suc ho xno . Dos vans MEO Ls eter Sep 9: Tortiodkts On espta lek bs ere pean j OP BL REG Gere \oop te tobe input, SG subjonkh trons Sod 6 append Rom to Re bst aep AY cobkahabo Ro ANQNOQg res, by ving Be cua of rons, tay tho Dosmbon 6h Swbbjackh Step Sr 9@ “Re conditional stake ments fo dokerrrming Ro awode \ored on Ro AVQNOQQ Maonkd avep Gr print Po SNQNOGe — Prart ant ade & proyram:. subject marks = £3 for Vin mange Cs)! rok = Stood Grpuk Center mossy for S iy »y eit de agen SR EMS) ONE _ Pros < task a Len (oubpet _ pros) 4 Coverage _ ranks S$ = 40): " Qrode = ‘! aU Croce aneroge — rol® 2 G0) + {rode = sp AE Ge «= AVEO O — reams < 90): | Qrade 2 yg: | [2&5 Go z = OVE MQ? — ross < to): | Srodo = sg! laksa s | Qrade = 'p' Print Cg“ AVe~OQQ wooly - faveroqe crank’: . af") PREC Grade + {grade?*) L_| oskpot Enter mals for whack © 2 es Entax rons for subjast a Enter rend for sobpch 3: 48 Entex mostly for Subyck A | 64 Enpery moxhs fos subbjaak sae AYerage pogo, & Bho: brad. a _ Bo - 5|Daanelop o pyon pram to gusap too nomked Caring boo vadatles). PlaysrfBiens Step ts gtant step 2° Read Re nuns | Step 2. Display Re nwo before — Sutapping, step 4 : psvan Re valse S rom j bo ae [step © L Astiqn Bo volks ef NM? to nanny step 4 + ais ploy Ro nasnbacy BS tor SMPPP ing. 1 flop 4. chop Progen - nary s int Gapat © enter Re Fost ) nvenben +) ' Nova = int Grpat Center Fo cessed Ausmoar = *)) Print © poperve Ssppira 2") Aus, aerns) HIV, Nosy — Mera, AWN) Pront © aster SubBPPing £7) HM, M4) ookpu Aen Putor ‘Qo Srrsk nurmben 1. S rote ho Second — number 9 Before SMAPET OM, 25,9 AY ax g VENPP Ta, a)to vyite 2 palon Progvaen to Krd Fo wen of fivsk sat catusol | Nusnhon « | plpritRens + Jstep oi: gtoot output - Entes a povitive \nteqee Al & Be Sum OF Bo wet © rakonal HusnorsA ee Ls bled uete & Pon ~ PROACOA ts “select A vardom dlement from a Vist, ark, AeBonavy Galss) onk 2 Sle Form F divactory . wae vondom choice O. plans hens - ep (5 stot step 2. rngost rracdomn ard 08 step 34 exeato a list wr — some Interges — Valo step A ft Pent & somdymly, chose element f {rordom . choice Cet Cry, dich. vabnes, 4) 4°) Anecbsy, poh = */podk to /youre/ dixerteny! Set 0 - diveckowy = Ts ses § \0 049. Vetdirg CAINR heresy path) 44 og. pa. isfile Cog. pot . join Chivedory ~ pork, #)9J Print CE” Random Clg Freon fic Avvacktrey 9 vrarchom . choice Cgiles-in- Secerkey, loapul %) Rordom ahement from He Vet 3 8 lyordew ebonzet gram Ro sak tg | Rarchom valuo Brom = Re dickorosy + 20g Random Fle fom ARQ Qe chery, 5 | example ~ Me txt Pay a) iseye A POgQvam to or eake i Conead e erate amd print & SEviHQ ord caceasring — avb- shrioQ From Qiven aber plgoahons - sap 1: stot - step 2 3 erreako & SENG A \ “ ‘ ne SEQp Rot can taterate wow Re sty 1 * otd asd ator? tw ones BEG. step At print Re concoke nate Serving Step © Recs gubstvirg using inden of ©, st=P bt pAnt eubst-ving, Program 5 - initiol - seMirg ~ *palto, " [contatenated. stvirg = initial - akring + | ® seer |" Pint C conateraded _ giving) | avbsh lg - eancatenated — ats ing to .ed | Print (subs ting ) + oodpuk Hello, world, Hello t}b) wevelap a python program to check \£ Be given string 4k palindwome or not Alger Ren’ - step 1. stant r step Q¢ Accept a song Syom Re viorr step 37 clean We Gaing step at chock palinkvame jstep s+ print, re aRe stvirg ig equal | i to WS wevexge, set vesoit to } "18" tls wsa “4c wot” SI2P G2 stop Praga + - jwacrr ‘apot = input Center a serving.) _ abeing = wer_) t ro, | cleaned ng = wey —\npat ar oo Co to presuih = U8" ie : cloanad. ¢tvirg == cleaned string. rf else + As nok” Pecint co +o iver sting, Gor hk} a palirdwome. ) voiput Ny FAK Sten, 1 Madan re Veen kbving 48 palindyarne . gladyewite a pyRon Progvam — ts get a Sina\e stviag &xOM tO given stringy seperated by a — SPAKL and sop Ginst $00 chowanbers 0F eack skvivg _ ample wwpak > Yobe! xyz! Expected wesult + “xy! ab’, c | Algorithen- | ayep tt vtart atep © | Toke feo stg’ [step 3 5 Seip Re srst 00 chasacter h ae ee ee | step 4. eancabenate 2 suspect ating aeporaked by & Spat step og + Pein the sretutl step 6 i stop. , Prrogeram © = inpuk— stv) = abe! Inpuk- stv s ‘xyz result = inpok stying s Trays inpot — sth Gayaryory \nput— styvi Got inpuk— stv 2 Tory print (weswt) oakp uly - owe abz Jb) develop a puthon Progam ty eind qe igqgeat of 2 awsmbexrg Urine bonita 1G... cae stakement. | Algorithrs : e }atep tt : etext step 2 compare Q@ fiwsb aselban Re secand — ayenbon step 3 aa Num1 4S Gveakey os Sqwak to amo . COMPAR? Dor oi Ro AWA, » Th nummy 18 greakey ov aaual fo nwMNQe Hom ie Do Jorrgert oerwise rama j¢ \ongyeat atop [Tt pom 2404 NWA. ov Step 4 AS net greater ov DM? , Hgompane AWM . step RY x Noma ig qreaker oy eqrok tO nymd, noma i | Xo darqekt . oRonwise | | Noms 36 e Sanqert. | | Progra | 0 gars J nem = int G pot Center fhe ost - mwena = int Gopuk Center Re second Nomben? “yy Aven 3 = in Goput Center seit ah 167 Coon ty 2 Ao) 4 if Cami > = avd) 2 Lorgest = nuns dyes Longest = vrs Iso 5 wf (nono se nom) + haxqest = num2 dae: Losrq eat = NVM Print C the Yorayest avebben 18 4) Jorqeat] ovkpak le lentes Mo Fyt gombern < ¢ J enter We seeord — qumben + c entex the ay Doben + w \tRe Sanger f aumben 1S Le 1D wale a Pyhon Pg Mm fo evoke ao Heh From Men ch iy nvmiban ard HS EE, aE wople . Algor ith ony step 4 2 gtaxt step 2. avaate a Vist roamed oriqirall HWek wilh a hstiogs step SF wei ai Rt carmprehen sion to crate & new Let, aslo Wct » bay Htowakt Revough nach nebo in OFA eal — last KP Ar EsOKA cach number create a tuple canta iniog, Re. | Merb ard its eube 109 Groen, pam #7 3) step st print Re ginal eaaba-lict step &e stop, ; Prageram | - etginah Viet = B.2,3,4 sh exbe- List = TGaum, num #4 23 In estaiml shh Print (cobollist) Osspud © - (Oud Cas), 03,94),C4a do (5, 125) ‘ b) Read wo sik TA 7 pint sue conAgn chowackex (sn lboth stri ng& ard Be want of fer Algorsth nt - oF ate 4 tox “ step & > Accept two syirga Fron Be, wren. | { , — - | Step 2 1 convert coach SONG, te a gat irs he | | stap A 2 Ficd R wememen chovarty -wS by Taleing ahs intenceck jon of aes seth step s . Ttermate ever do cemmon chonactexs ard count Reve Deeurxenca in woth — abring’. gop & = print gach common chorract & MQ NY ks wont step F . stop, POAT BL = Stvings + \epot Cc entow De gest stg | sting 3 = iopat Center ARe secon tying . ) Sef. = sot Csto\ng ) leet a= sok (atrrieg2) / aaron. chews = gett. intersection Cxeb2) Sox chars Wn carne charg ¢ count = min Cate sogs eanurr Chor), | string. count Coho yy | point (4° chayacter * gchor 4 ' count + gesunt ") ° ouspol = Entex the fixst stxinq 2 Hello Entex te gacond string chanacte¥ ro, 5 sand count <4 chowactay 12, wonk +2 a) wnita a Python Program — to find Re Avpleate clement from \wst Rigert fans step dor stant stop 9 3 Initialize step 3 ) Tkevote Brough aock clemed in Bo \sab }stap At cahech if Re element ‘8 | in 4tRo Seen aot. Ault Th yeds add *. es the Avplicat es seb A.o' xh no, add it te the seen sot step sy pnt she ket of dvplicater — ements step 6 + stop Progra * + my isk = Wma ray 2) duplicator + avk os 5, bial geen = sebcy kos lement io conn. vel : VE ehement IA seen , Auplicoles + add Calesnent) re Seen. odd Coherent) | print Cvuple ake elements Died ¢ daplac ates) | owkpuk t- puplrcake oloments . fa as ve.) b) ede a Python pregsam — to pyRon Ferd We rst, and Longest — elament | 7 a dat i . | Alagorion! - istep boo etorrt a i aap 2 i chech if Be Gel bos atleast two elements step 3 + 3 vet, oxint. “hel should hove atleast two alernoents! step A Find Ro frost _ longest element wring! Re mat Sanckion on Re Vast steeP S > Ramove ae Kost Vosges element from Re last. aep & 1 Find Re seemed Jargort clement VS og Re ena Sornckion Bn Bo wet step 4 paint Re negate } { | step 2 2 stop, | PROQVT AM?) - | emorrs = T9,5, 8.2, 49 | 1§ Sew Cnombens > 295 | peint Clst should boxe atleast tooo ehemmarthd.") eke t Fixst— Locmest = moan Caumbers) numbers vrarneve Ltivst. Loaqest) sacond_ Jorqgest = max tnounbers) Print Cust foageast clement 2! Fixst_ loxgeit) Pr\ at Cond Locroat akernent >! gacord— Sones ) ovat > - ist § Loceqgest ehement tle anc Reegest olemment =: buple fm ta) Watts a Python Pisyrane unpack a tupl sdeveral variable and Use 4 opsrations Algeathon Step Unpack the tuple trto voate bles Step 21 Usa He t operator * caleulate the dum of the vonriable Stp 3: Ratuan the acult Prognem.- def upack- and add UPD! variables Oyb yo ~tup Varta bles result sat bte return pub my- tpde = (1,2 ,3) sesult _ sum = pack _ and -ovdel { my. tu pie) print ("Result 2", geautt: sum) - Result 2b vam te add an fim fa a the by Watte a Python preg tuple unin sal | Alaox! thin ‘- Stipr: Define o function add— Mam. to. tupee thet tukes original ~ tupdte and new. Hem ad | Povo madors | stpa ;tvtek of new tupte new. tu ple by concatenatin original tuple with tne fer) using Hat optretoy - | SBP Ss Return the new tu ple | Px oom t- ae odd. Him to tuple Coviginal tupte, new. fam) nau. ti pode =o ginal ~tuplet (nate tem’) veturn newt ple my-tupde= t1y9,3) Rew clement = 1 result tute = odd them ~ to - tuple Cmy- ttepte , prind Cnes itt ple) . het. etement-) | out ped Result 1a, ayy 19. a) eile o Python Pro sam to find the factovial he Given number using ALtuision Algor lth nm vl Re Supls Defint a function first vepentd- word an toby & btrin inpud = string as & parame 7 | Spa : Split the in put Ataing into o Lat of words using Apt (a. pepe: Tafuinttes on empty dct word - bab to feeejp trnch of tenlgue Words encountered Step Wi Titra through wach uord in the bist : Tf the word ua cbrandy th the werdl- def, ration Moa the frist 4 probed word | Sth 5. Tne speated word fe found, return None. pier cy {frst _ Te pected _ word Un pat = string) : words = fn uct tring ‘ Splite ?- Word — bat - 6.4) ° Jor word In Wordly : iy Word in Word set - utitn word ede: Word ast. add lword) Autieyn None | Input _ teoct ="Thes is on sromple An 20m pe of a acpeatid word." vyesalt = first - Aupeated - werd Cinput ~ tert ) Print C4" the inst vs pasted word Is: prssult ¥ Hy cap Result: The fiast vepeoted word o : an. a by With a Python to fied the P's! va peataal word fn a q nn string She p! ‘ Dade a function foctorial thed takes an tn-tega nak o para ety Shp?» Boge com 174 wie o av) eens! {bore CON fev fovtortal) Step ay Recursive cose | othevwae by the foctortal of nnt- , aeturn9 roulti peed Step He Exam ple tage | Set a evita butt num bey ko tle oles Pood in prt cal the facterial SJunciton cetth thad numbers andl print Fhe Acsult od a te find the factorial of a 19.) A) Cook o Python Pregsam to fied the factorial of given num ber using ALcursion Alger lth ny vl Stup | 2 Define o function inst vejeotid— werd as Leber a pads inpat stating as a parameter | Shp a : Split the in pu Ataing into 0 Aut ey woayald using Api (y . SOp 3% Tatitatiee on ampty det word be te feat > broek | *} nique words encountered . SOp h Tterats through tach word ta the Lat: TY tht werd uh cbrandy tr the werd def , ration Moa the frist 4 peaked word _ Step 5. 14 no wapeated word ts found , retuya None. oie arf fFest _ Te pected - word Unput . string) : Words = fn uf atring. split, )- Word — bat - 54) ° for word th werdls : Ff word in worl set - utisn word wale + Loord ait, Adtievy None add ( werd) Input _ tect ="Tha is an zxom ple An £ampte of a ne peat d word." wosult - fivst Mepeated _ werd tinpak ~ tact } | print ( fi" The fivst v2 peated werd fst presett yD. | out put 4- | Result» The frst Yepeodte d word & * an. ————— ern I. by writ _ fytias fo find the first Vepected ord tno given String. Algorithm :- Step be Define a function factorial thed takes an frigey nok a pecva matey - Sipe: Base cove 174 ns o ov) , Teturn (bore Couse jer factorial) Ste pas Reursive cam totherwode, Attuvan multi prted by the foctortal oF nea. Sep yy Exam ple Usage | Set a vortabie number to tHe clutred in pot eal the factorial function twith thed numbery and print the Acsult | oa | Risa _ TAM) | Ee feaieial tals | ifn==0 owne=t= ve turn | lhe + veturn n* dactevial tn-1) | num hey wesult — tectovial (numbay) . Print Cb" The tactorial of fnumery a: | ou put {rvsultt y") Acsuit : The factorial OF ty tia0 i—e-2H,,,,,,,,———— 13. a) Wafte a Python program to 1 move du olicotes Jom a List . Lee Stipl Define o function remove — clt phic ates that takes o List inpul AS pa Trittalize on mpby Liat unique alomenk - Stb aT teveke through toch item tr the thpué cit ~ Lat as a povometey unig — Liat to store “TY the tim dy not already Tn ten ta Lit, odd ft to Hy tt | sop Ry turn the Und que Litt - Z Program | ati dus plicates Cinpud ~ dist )* tanigue tut = 0 jo thm tr (nput adirt : | i} ftum pot tn untae . Lae: untae — Lat o ppend Cftee 3 vebern unique — tisk - eriginal ust -Diy2 324 yy SJ suedulk . Ast = ~o2moys _ du folbcates Coriginal - tt pint CH" The itt without clusp-Le ates i {Aude ist yy out put ~ ae Result te Ot wot bout duplicate, Ui Chessy ye7, 3. bY Welt, a python Mneor aeoroh . preg ram to joertor m Stpt: Dative a function lintey- Searveh that taker oa uit Ist and a toxget velour target OL porameterys - Sopa Tera thaeugh gach aebinienk: Ti tha ae wing anumerate - Supa: y the wrtent shement i equel to the torgat vedue , actiorn the fnden i inding the | Stpys Ly the Joop tom ple tes with of pinay | tovgt , Adtiern - { Span F af Wusor search { Ist 7 forget ): ov finde y Ptem fn | ANU coke List y+ | TY} Piem -- torgat j Yeturn Index . Yetury — my. Ube =€a)4, WWyeiyay , Lorry ~Vabue = 4 Tah alt = Bhar pay eh Cmy. it, bengal vost). PY Acgulk py. Print Gh" ftevguk_ vadue Y found at inde { result "5. thie | Print CF Horget vate} nak found Tn the lee" | Spy: OS Bsult 2 4 found et Pridon 3 | 19) Code om Python program to accept o shina 7 FAVES hr ind: the String | check whether the string Isa palin Noms. and eae the yesult - Algertthnn ss Stapt Dafne a function i palindyome that takes a atying Input. Stving 1b a pararneter » Stepa: Reverse Hue stving using Siting (Lia. Seb 3: hack tf the original strin Niversecd varsion . Return Tras tf 6 0 palindvome vetern False . 4 cs tqpsal to Hs y Other wee SUP: Exampate Usage : Ta t~ potlinelyo x faancta lef ts. palindrome tin WUVersed sey; put _ String Es 'j Yeturn Pr put - Stving - : Never sed< Sty in User fn pub FInput ("Ente 0 String ! “ pet eeting dy: ng = by Die 6 Pilla Pregeam te Gaunt Gg rowhor yesutt = f5_ podin drome (user fn put) ft yasult | ; , print C4" fuser input $ ba ppotind ome ) print (Ff usey- input ¥ ois not a palindrome. Result ‘Entry 9 string : devel devil us om polindyome - Vowels fn Attng Algorithm '- | Stpl ‘Define & Function Count vowels that takes a | Stving Input - String O48 oO povametey , Sttpo : Uvtak a dtrin Vouels tontarning oll the Vourel chervactrys . Stipa Trittebeer 9 County variable Lunt to, . Sip ys Thyot through zach chovecty in the input sty ing | and Hae thovacky Bo Vowel, Thevement the | Lountey . | SRPS Return the tinal tount . Stupb: (Sup Exomiobe tags ' Toles USeY frpul, Coll the tounk_ Vewals functt on, and print the yesull . Progrecm ie de} count vousls Cinpuf- String): vowdld= “a etouarron” count =» for Choy Ph in put -stving: Tf thoy in vowels : count+=) wettrn count - User. input. input C" Enter a bring 2). Nesulk =count_vewals user. fn jout ) PrNECE numbsy of vowels fo'Susay_ in pub y! Bo! frosty "). na Rasutt : Entry Atting : Hallo world The numbey Of Vouvsls th” Helly World’ Bi3. 1) writ & Python pro Worcls Pra Teak ead Step ts Define 0 function most. frequent — words that tokyo Like path fi. poth ond an optional Pavemeby pum words Cdefoutt #55) as tq Spo : Rood He content Of the Fi and ean it Namevin i‘ Non-albhenumeri'e Cheract vs o tonvarting to loweycose - Sp: Sphit the cleaned tet into words. Stepy : Ve Lountey to count word prequen elas using most Steps - Retvisve the most tofmon worvels y | tommon muthod - | | most —frequent — vy, ds Yik- path, num. | de} mos fe que ov Led With open ( file peth ‘yA Jos Fike trak= File. vead ty theaned_ Ook ote SUbLY Wes Leaky, Worels = ceoned _ fot. sputey lowere). Word - towns 2 i word -tounts , most Nttern most Hite. path Vesulk - -tommon (num worrals > . - lommon ~- words . . "Sempate tent dnb! ost -Prequent — Worels ( file _ poth) Pree th wnat FH PME Lov ols ref esubey but put :- Result : The most CCSompt ', 4 frequent Words Ore: DMC 29, thes 19, C wore D1 ore', oy 15 bybovite « python program to find the ents of Shape | Alapvithm :- ipr j © funckon Yaeclangt, area that takes |Stepa: Mutbiply the Lenoth end width be cCalleubate the | oreg [Sktps: Return the cateubabd aven [Kean the Jungth and width of a vedangi as para meters | olf Yactangte - or20 ( Length width): ~ablin Lengtn® width : ererth = float Cin put ¢ "Entry the dangth of the vackong tes "5 ngth, Yoidth) Sactocng te G ‘foreay'y area = ‘ectane se. ~ OLR ( fy print UF" The ey «Splet the une fto a tint of words using Line Spite b Sepy: Print thy Untaue words In alphabuticnl Oveley: «Print 2och word In Hy 4orked ordey of the Wate worels set. Progtiam «- a tl 7 Undoyee - words (Fil path + Wha words = st ( tay: , : with open (file path, by 1) as Fil: for Une in files Words - Ling “Splt(). JOY word f, words: Chand. word = Word Stripes (leaned _ word «tsa Unique . words add Sov word fn Sovied Cuuntyur — words) Print (word > . “ALC eT ER The Phacy: sowsre) Fy Cclaned - Wore) stxcept filcnot jound Exrwyt . prin y Vevey: File a geet ound -'f Fu. Path= Your - trek _ fie sue ' print —Uniaue words CL: -Jath) . oud but *- ae banana therry . b) Develo, & python preg vam “to find the average Sinum?,ouma, num>, Sum of the thre numbers ¢ = hem) + numa} numa . Stepa ~ Codeul eke the owrvoee Steps: Return py Prine the ¢, ea num = J loot ( {pet ( MUM 9 = plot Cin Num 3- + look ¢ toted - (ONY = tetols2. oleut ated OMere a . “Entey He fivst numbey : put cu Entry the Szconol input ("Enter the Nami thom + mum . Ove rag = total / 2 Print C4" Thy Auras, frum 84 es ")) Pein ete third hum bay * "yy 2 Of fourmy y Fnum2y and “$ average "9 P out peat = Oe Enter the first number: to Entey the Second number: ig Entey the thivd numbev soo The Ove rage Of lo 0; 'S-o, and 20.0 & VIS NM. 0) WH a Sevipt named topyfilr. py This Acript Should Prompt tle Usey for the mamed ot bwo teat fides thy Lontentg OF He first fie Should ba fo pet OM wrtthn to the Setond file. Algovith mir Stepo 1s Prom pt the uber tor the named O+ tuo | tent ites : input — file - ome onal ou pul File | Rom . (Sep2 1 Try te va. Open te first file | inpuk— file rams Jon Yeodl ing bead the ton tents of the fixe - file into Ste Varvlable pile -oontents ¢. | | Steps Hondte Sxteptions : oft one or b | nob found input — tile rans = Input CU Enby 4th name of He First tak Fu s vy, Oe puke — File name = inpud CS Eney He name Of He Second trot pile"), oth of the Speapid tile ave rPYINE cn 2YYOY MeBbe.g-e | - —! ty with open CUinput = filename, by!) OS inpuk_ tile: fil — contents - input fil. vead cy | with open Loutput- fil name, bw!) ae - Hk: oud pub _ File wriky yil -tontnG ) . p | PrPEG| Mcontents from \F inpuk file nome! | Sucess tly topud to * foutput. file name ¥!, ") Out put ;— | CARRE Enky the name of the pivse teat fie = inpuk txt Erey the Nome of Hw Accond teak fie * Dut put tet tontents qrom ‘input .-Lxt , SUCCess fully Lop ced te ha b) Devatop o python program to tind the sum of oligits fn an integer using wht state ment by greta the inpide “fora Eke wae Algorithm t- we n Integezy input yom the UbLY; nun Spi) GF on Trg pa f Stop 2: Enitiali ze SUM _ of -clig tks too Stup 3 * 4 12 grreotey than od. &: Extract the Lest Lig at Walag chtgute = num: lor be Stpy! Display “Use while leop 40 tyedt ab long O& NUM Hu Aum of digit printf" The Gum Of aigtly fr Hae entered ertegey eh ; f Surm —of dy ie"). ea Num= int 1 impesk ("Enter an integer: "y) Sum . of eg du =O Whik »nm >: egal enum 710 Sum — of_ diy} ail Fee hum / —_ —_ aan print Lf Tha gun of digs fn tha snteved fake gay | Bf sum of | dig 30)" Outpub 1 = an integer io Tak « J = Aum of ata. its In tha centered integer b: 18 |0) Daw oe OY Vol aa SES : Q7ram for Vo, a, ediottly Validate ulng Leceptionad Handling Prati in python LEX! eet Me votty ts De ox not). Maoxithrn :- ; Sbpre tat Input from the usey —_ Gop Vote Stepas Ure ao Evy errept block py haddte Jootential . ANTOYS Fa tonvart the in pub age t) an intosy Cink CvelLy aaa). b) Check fy the age ts JUN theo 1, tH Avy roe a Value Evroy with o% sped tic me Mode. cy) Lf no evrors octets y py ink O memes frdicadbing He ee YG Volid for voting, Prego. - water _og.e =I npuk U'E ntex your aga. My. try: age cint (vote age) ‘} OGL d 18: VOU Voli exvvow ("votty mutt ba of Lect WW yaerrs old.) print (Voted Voter age tovote 7) Anuspe Volur Exyor coy Ve! plik: Cy ewer vay") Yow on legible output :- woe Enter Your ege sis Exrey ivory mut be ot Lest ly a 7 old Ww, b) Write a Python Pregre nn tonverto Pruptir a String : | Algoxiskhm :- | Stp i: Define ‘a tuple + my tpde Step 2: UAC the jeln method atong wilh map bo tonvert eoth etment of the Uijote toa caer Bs ca) map UStyy rey — Gate D Converts sock benent of te ba poute ta teting J by Ss fol tas.) cndedtnindes Bane Statooys frie om Aing Le Atring . Sap 3 Store Hu peso Pata pee Sti Shp y ! DAsptoy He Lon wey J ng dtring 5 print CP The Lonvevtzal Striog trom the Top te; i Fup ~ String y Fam ci - MY per = L142 43,%a%, 6,?, ber) Cups _ Bev da « uu join Lmapl Sty, my - trpteyy print Chur, _ © Convayted String f ¥6 mn Hae pe frupte - “At ing a 15 ee | Thee Lonvert of String from Ate tapes l298abe. ‘4 —— Duvite ai Python clase fo Nevers © atic wend Loy, wore Alger > - step Vor Stavt step a : aptit Re input stysog Anko a Bst of words WAIN, Re spito meihod step a P Revewe Reo Vick of cords uaine arene \ st sheing Uh ~13) StSP At sein Re veverced qanedd into a stving wQANG Ro jena meihed wl a qa os dhe Separator step s 2 step Programs - Finput— stvirg = “Welle world ” weet = input. sbtirg - ahito weverged _ words = words Fs av mreversed— st =). doin Cxrversod — esos) Print (yeversed_ st) rostpake nawvid Wello WDA prime dombey 12 ayy \nboge’ grea har Ron Ono Wot is woly Awisikle Loy one oh Weel? weite O Sanction Pat Astorranes whoo 9 vot is Pavameton i8 Perme, rok OOOH true i it is, olleveive — Fabre AlgorvR rss. step 1 2 sint step a sx} ae gnen Somber Sa leas Pan ox aqal 2 | sehen Fabre Grol a pune smn bor) step 3. : shevale from 8 to Woo Spare soot of WE Yew Horney < ) ‘ step 4 iT Pe womber ie divieikle by any Tnteaey in ale AAD rekon PAO Cool Pima Herat step st 4 Wi ‘ : P at ne Awicen 48 Sound pevwtoon THER CIR a parteng dyn hon) step 6 + step. Prvgrrars : e Member. fo- check « rt TE pasrbar, to- check = 14 Pant G” {nomben to-check3 ig hob 8 ene ausrbon.*) ae: pe fos Van roOANG, @ Go, int Cruenbon — be _ cheek "RO. s) + % i VF nacloar- to-chock x j==0+ Pant (6 Lmumben. te checked ig not & Peng norben.") Brealk else: ‘ . peint C4" Lrumbon. te- check 3 is @ grime nwsnben.") joukpul: - L$ FS Qe PRM Doobonr —— =o ——— si ©) simulate Bouncing Balk “uathg pygame algorRons - step it Starck step 2 3 python mut be atalled on | | | | | | | fa TY goo earmpokey Fest ' step 3: Enstall Pagamisg Wing 7 PIP atop 4 r opan & new eyahon se and step § + eek Sizs by edt ard sep 6 + gat backyard ard apeed step t + lead ho ball rage and step step 9 7a \a\\ ike edge of the step step ‘natal Pygame” 1 @ command hal\. 7 ' \mpant Sy ard PAQame. height of bal, ereah® nectarale One eOVer\og, Re \nog.2 Fy meve the bal in speciticd speak. SEKREN —- WRNAAQQ Re Aiseckion wy eveake ngieryo lop gourd repeat step ¢ and 9 wat\) The SOK gngks Ww. step. oF — —y ee | | | Sys. odk © Preeqrrarn + - , TePort sys. Paqame Pagame. inito size = wa, height = gov, 400 speed = ff, background < Cass .ass, a 55) Sereen = Pygame . digg. cet - mode (size) Pagame. display. cet caption ( BOOTE\TD, yall} ball = pagame. image. trad Chall. Poy") hailveet = ball. got veckO wile Ut ' Sow event WW Pygame. @wont. get o- 1§ event. type == PYgame .QLoiTs tallwect = balroct. move Cspecc VF ballwec lett 20 oF Lallyert . vidats wid speed Loy = - Speed To] i§ ballweeb- top l _ ol |b) wte Ppyhon POVTAM fo TAMove avplicakes from a ask “algo tims - step bs start step a+ event a Last fo gtore elarnent& ‘ Jstep 3: thetake Arwudy each damant in oe inpak Ust> step 4 chek i Re olemont 28 not already I Re Mist } stee v ~ th not, ada Re omenks io 2 \s step G2 Re yerukh wontains onlsy Re Unique elamanks — Fron ake st Step 4 = shop. PVOAVAM - seek =a a. 3 orb He wna — eb = £9 lows Sher in smaivak st . | “hf {bern mel V9 equa ust nique Veh. oppersh Gitern) IPent Comainal. acti. oie act) Pont Crist otk dvplicates ~amoved © ” vique —\\st) output + - wana Ust « fo,38, a, DBT, ALE A ak Swplreattes qemeved + Giagi.a Sibi t, gh

You might also like