0% found this document useful (0 votes)
24 views5 pages

PPS Reduction

Udydududjfjcjcjficu
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)
24 views5 pages

PPS Reduction

Udydududjfjcjcjficu
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/ 5
KUNI ' QD) Whatis function ? Explain Call te econ funetone) The funchion iS 4 block of instruction or code! DThe function is @ block of Statement. syntax- def Function name (2! ® Every Suncsion 16 species by 4 name, . Statement block Wt can be defined by ‘def" Keyword. — [Ex det gh ; Etmchoe Gl TJ Opece we define a Functien we need Te calif. nat Peer) ‘ AD Because it nevex TUN. Wi thouk Calling 4 fupcbien. D That means once we calla function thon program tal cecute inden Ye Function. natax Functionnamecy FR" vishal) x . ao S def vishal): Setpuk > pnnt ("VsHaL Pawar) HELLO OF AR Print CELLO DEA G) VISHAL PawaR J vishal () ~ 9D Lambda Panction? —_ > dD Lambda & without name Luith noymal function | 22ete= feria raiment : Doambda ae het yet Gntais and Slaeee rane, | Rantis arsaments: capression With normal Punction we use keyword Jee. SEE dd = Lambda a, 620d it) Lambda Function iS used to addition 6 -bwe numbers. Print (add (40,29) 7 See oF Ten fla Bancon: The lars bie Punotian is teed ones Boo i! dny name for Oy ‘De, . DP hunt ie ionive taint fuse ananyrod S ancl inside another Functie, ~ 93\_Disserence kA Ween Local ad global varidbies 9-5) Types of Argument 7 | | > “Local Variable [Global Vaviebles > D fusi:tional Arguments DA variobie whi [BA Variable which 19 |i) These re Fhe basictypes of arguments ENN abies used takstie resin Which dre passed fe faction besed on their “WD TE cain 6 aecesed within|D Et can beactssible | Positions. Ce dehabs (uty: ! a function only, notin | throughout the i Whele program $709 Tamm, aes.) mis") DT eanezists as long |The glo bal Variable Outputs / 95 that Function is Terains Shroughout He! executing, enhie prigtamm xtcny FU Healer) Anu nt also cae 2S + Dt Spepseres 45 focal] Ibi sgrerdy pot | f wor. iin ee 0 called ctrguey Eanes more mall Pesore Sang Punch Tn keyword avgumenbs the value are vats Because the values cannot | Cdn change she values | ssociajed tuith name. _ be changed outside the Funct OF global variable ivf OF Slo bal | __ 1) Sp keyword argument posi fion ov order doesnt “D default Arguments= Doefault values indicute Phat lex: coh ag: mi =d+ a Sou “the Punction 4734 ments twill ke value #Pno dyument value is passed ddring Function call. ; The dePault Value is assigned by Using, esis Dope tor. i) Tt iSin theferm key wordname =value aie dR add (0,5 = 2)" cod+h Snack, W0-oP ATIUMENES, WE can passed to 4 -LancAsion, Print (Additienis’: O[MByusing Hhese Srguments, we can bss de ada (3,9) i oe ¥) *args inFunckon definations in puthey + Adiitioniete ED Tig sen cui Tar of arguments od fanehin 1 Wed ; Ex: dep hi(*names)! output? Hellovras Holloyesh Haltoj uy | For nding 5 Names: | ‘ _ bring Hello" name) | | Witer 43 (62,409) )| Addition is 49 fone The vari@le lens a Altariable lenakh drgUIMEMES* Very usckal Whocue Onn 78 Seam aT nob know He imber oP values in-fun li) Xt {5 Used-fo PASS 4 nOn—kogWord, variable-length Srguments hen, ou i Cray, “gash”, “jdy") CS ven =. a Standard libtay ef modules. “ 2 Pathon's sendord libyary is very Srhesive, offering a) Module 15 497047 of-fundsion. ide Tange oF Laukities. The modules Via ‘art pre- insted. , dD rete ray nln debi itn fay iO AON an8 ele Shima bray, many variables dndFanctiOns. But you | Mervthen standard hirury is 4 csllechon of sure madules ~ Want fouse selected Variables ang | FCCSSIbE te py thin P2CST AMM H8 Simpl fy the Proyramming unctions. i) These are two types: | PF°255 an) rem Ving the need to GBIF Tewrite Cary 4 Used man DPre defines Module meee ; DWe conser, : | \ \ _.Thene. of Functions afredy defined.| by dyany er USE oF medulys desined in standayg li bray ‘ Sel ute ashort nae on a mcdule, > _DAlleython program Files are dmodule. . YPIN9 She Pollavwing Command onthe prompt window. §) Us Fined ad Some cone? Cmedules) hee. iaLtion 1S do nok dlygady Tipe Suen. 4Sed modul@S Pram standard library are So smath semail stardom «string eushig os “Unit 6k 99 Wher 8 FC? need of Filer Ey ; “ ££ xplain velutive and dbsoulte path of file, > Files D) ASie is collechin oP gba mporanen trav ‘stored on a computer or other device. D File can can Cntain various ture of informotinsuch ds Heat, imd905, dudyo, vid€0 dndother “ie 7 . ey 4 ize i Hi on cuY compu fest Needof Fite = Dara Storage: File allow us to sheré dnd ovgdniz€ inform tei rs, argo ae “shoring = File can be shared with ethors, ei Seer rough ennails Cloud storage services, oy Ther MINS. 18) Backup dnd Becavery> Files canbe backedup to preteck Against dasd joss and can Neate the Clot of d System faire or etherdjsaster. | xRolative and Absoulte path of - DAn absouluse path lays contains therorh and the complete dire cv [st te seeeih en © Mack, Vocation of Fi). ji) Relative paths sn the oxhor hand, need 4a be com bine aero eee inorder Fo access a File. 4 Relative padh shirbS with wespeut to wrrrent a pine Mnoeore Hacks the leading shashes, fares a hes 2m Deore, Absolute path is cr\ Shwents\uc\@E_com.docre i 2} Ashe information necded -b leetté File BF Gm dow 1s |S Claes GAY TE ae Fi. Files und Folders Chained in the dbove Path. 93) Explain dsrethory methods. ; Ditere, Relative path may be UG\BE Cerm.doox. 5 i : a relative Path, i seecified, the Sipe pe with the current directory 49 create_an absolute Pith. 9-D Dif Ference vehwoen Teak and bine ‘ — Terk File Binary File I> D Geteing Grrvent working directory, | D Pata I Prsene ae the [ Deat eee inthe | meted in psn = Fev 9¢t ling the hdhe of form of characters. | eneadedform ww kin i The pln Fert 13 pr= The tet aah TRAE [fancies makina directory we Use the Function nde ow! f ; eos are st mle Hence EOE en cin nok be Grup -l ii) Even if sirole bit 15 che : 7 apa ed than the Fikegeysexrrtipl] O° Wing dire Ata. Forex: etd ma pg | DI can WePenes and |D TL can nor-redd using Fr Ge skin) Tedd Using Simpl? $ext | Ye fowk editor like iis bs ; laying dl Phe Fes ang s 6-0 : ) editor Hike note Pad. [notepad _ |S oe ating ai the Biles and sy 6—Sinec jovi ee Tike 1D TL can have application) inside a divecor> For listing the coy Uehara it oe si » oF nc cntensten OF drevory We US the method visowegte “VD Ex) Text Silt Ctx) Ex = D Bud Files Cine For ext impart og iD pas file Graf) |__D Video Fites Cmps) Prink (05.)ist dix) s 8) _Grea fing a Hew dine ctory= WE can uredte 4 new directory USin, mkdir() metnad mkdir Pemo-py 4 Removing the directory oF aline= : 2) AFINE can be deIeHeD Using Temave cy method, The *mdir() method removes dn empty OrCoteny i. 0.4) Explain dictionary Methods 2 ~ ca ing inte t 3 4) D) Adding bem 1 Dichontry- - . we can ad the FHem-tt The dictioneny Pma-dic update mame’: “Zohn, age 36, hy rey 3h, DBemave item from dictionary? # DN . Yori) For removing In itm From yhe dictivnary my-dic Eneu-keat] = _ we use the keyword ded. : | ew _value i 1 Dupdating the value of the dich unary > nina Wwe am update fhe value of she dirtionaTy mn . WS direOkly assignment fhe wlue to my-dick-pop (age None) § _ Corresponding key Posi tin. | ## longoyh . 3) Urecking eng he | die -lengih=len(mydick) The len) Punchian 3v@ Yhe nun bor of | Print (“updated byotionarys” ny — dit) rant Clenaih i a ¥) “3 Finchan __ randy 1", dict —lenyyy) int naar Doors () Funcrjan; $ dichondyy. ) THiS Functith dives lero th of dictionary, DTS ee eater a. Dp gives no. cPibemsin d dickehary | WT} oreares : Doct () Funcion = 4) Kea 0 Punctjon= 7 | DThis Punchian is ased took value Fer | Dist of heys Formal dotiondry ave given by Pairs in The dichonary. _2ivin key. wis Punctions._ . Svaluecy Puncans= PO) Update 0 -funchien = - Dist oF values Prom 4 dictiondey aregiven | D Functicn Jo ado djohiondry to dnoyhor dickiondy by This Fun ction, 8 One dictionary 1S ddded Fo Another Air nury With at its key—udlue fairs. 9D) Explain File handling methods? yes Using Fenchiens ov methods Provided bY pregrdn= 4) Openi = DTWis merthad inv fa Pine yen usile fox redding, Writting OY both. ; : Dey ‘oul meouires specifying the Fle path And made Cread, WI}E, append, e4¢) 5 aa pat Once atile 18, OPeACd For redding, Vis. mefhed involyes redding data Bat Ten by Jing by line ov in hunks, dnd string ivin variables or data Fr ee econ further. pTeeSSiN9. a — va ng dd siuhen wSile 18 aponed POT WYFHhg, This method VelVeS Writing oata a2 Tithe or overwriting @miSting canton’. §) Pata Gin be written in vaerious Sormat, Saugh as ter cy binary: ain _ 2) Closing Piles = 3 Fedding Sram oF writing Fo CFNC; 59's CSsentia] to close The Sle to aa anaes nde ensure that an QuB ered gaia jo Wristen todish- H) This methad involves sing Punctions of MANIIS provid by Yhe Prrgram mig language toclose thefile. eh - 2) Orediing File= PITA File Goes hor CASE, ib can 0€ ored bed Using File handling MoFhads, This invalves onecisying The-Rile Path and The mode Poy creating tne Flees. perma © D Fonction Fe ado dichonayy to Another dicHondry. 9 Update C) Function F h ti jimmy #83 yo another dichundyy with ais Key—value pairs. QT kv Aa on fet eer a3€ 9.4) Dash fy strings are imatabie with examyle. , & > Strings ‘are ‘Parmurte te De We canoe Sangeshe existingstrings. fares >>>msg = “Good Morning” >> >ms9 fe] =%y’ 2B Wee Error: ‘Str’ objects does not Support ibem assignment. 90 Beh ain Stim OYinak operwoy Wi Yh suctable example \ = € Format operator iS pspecified by using ‘/. op eraser. a & 1) for exe if wank fo display integer value then the farmab Sewence must bey. } 4, Similarly if we want to display String value then She Pormab SeWUence mast \ be 7S and Soon. W) Various format speqPiers dre enlisted in Theda ble > crsers (Genvérsion| rearing 9-3) Fxplain wih example iterating id | Sioned inkegor decimal | String. f signed integer decimal =, as shinee bits lamsisned hexauecimalClaués casey | DP bordtting the Shings by using Iunsighed hexidecimal Chighorcusg] -y -, 27 OOP, iterati \ ned he Tis like loops iterating. aR Eanes of i, Sc BO standing it displays” eauh chard her in Sting, ) ert Shy= "sun? { t | For dye i$ Sun: : lodting Rin’ ‘ormat | String (canver tS any pu Thon objec ie rt (nr) | using yepr) ___ | Suipuit 5 Bay ‘String Converts Gry python 8 ) Shiects using Str0)) f PERI ase Fin and nobiN oPerater instringS| 9-3) Explain o7d() and chy) Funchisn with * —DThe jn and notimare called 45 membership | sustable ox: i Her dre used Ja desermine ire eee emlon eb anpiney sang, |? Berd Tb reams Ihe ASCIT OT nek. ja) n> TH Tes ‘Tye? when Sub event Ibe sha ration: String ig Pend Luithin string atherufse False. 2 dhrc)-s Et retains the character W) Nobin~> Tt retuns ‘True ‘when Sabsiving aepresenied 69 ASCII number, ” iSnotPound within a String othorwis-€ 'Frue’. xr d= "VISHAL PAWAK” Gutpubs print (dca) ouput+ 6S , = vishal Fals Print (ord¢sy) 33 1 print (bin a) aa print (chy (és) B | Print (b net in a) Prink (chr (cons) a | 9.6) Explain String Format Operator wih Say Fable example. ings 7 OF Cencatenction*') concatenation meunsyun Logethen | 2-eeending: |) Us Stemtaiy th Wancatendtion Gmbining Si7In9 Using the V'operator | DAppending strings Usingphe iD For ex “Hello”. World” sxett dhe 4 =? operator. en _Setvat Helle world. ND) Foret gekeriion = : S="Hello” D Repe tation astring ma 4ple. dimes sing the . $+ “worse” * operator. Dfir ex rsp» #g ousput uput= Spspsp } Hello World \ Se inden I Searehes The String Fer Specified value and returns the position oF ' where it tuts found. EX Sty= ‘Hello World! outpub: 6° Print = GS. nde (Hworlae9) “By Siangay) Psabstring oF a S Pring 18 called Shee. ; os is astring opera ofan used bo exract 4 park oF any string basal pve ce ee tiie. Te eae Mioing is called) substring § ) ‘id eee TINS © a Dd or can, Seonabiak oF string Prom Jhe original stying ty A5ine pects) qlso KAown 98 slicing perso. \ D Syntaa- Sting name [starting —indea Fini shing Inder : i characker—iterd se] ~ : EXE Str ="fython Programming" Sint Coharackors from Ast do 6:", Sty fed Print ("oharachers From 8th anvourd:?”, Sty £7! erint (Jas two vharacters:" Stri-2: 1 Suiput> Charackers Prom Ast 4o 6 + Python. 3 charichers Prom ¥ enwords : Programming Last two chard Aerd | ns 3) Bail n string methods and nang. capairtalizt Sinst letter of string. ri Ts = j 22 indesing and ShiGing’ a > A)caprtalize J» This Panccbion 1S used es Ex> Str="helle” ~. oatpuc> Hellow rink (str. capitalize) Jen Gbring) = Returns length FWRESE in. Ext Str= “Hello” ewipub eS oe J evint (len (srr) a Ts SHrilg lePE padded With 2eras to atotal of Width charactors. Fi = Roku y DzFill (wideh) =k 4 also Tetains its son Croy ~ SsHis uyed with numbers dn BAe StrH'123 6" ea - ouipure 0000004234 coy grin (str. ZS (49) om ~- buspUye | T Chavachers in the String ERE Str= “Hello” 5 all Chard j i ret hue) hello OuspuTe qj lower 0 = oye cwwer cas. BOD Cnt a pan (ordre) HELLO | SASEIPUF Removes all jai poe Pe Oe Ca ai 0 a D) Strip 0 ee aa ain Greet) acct : D ttle OF Returns String nH case. PL Cn a : urput® The World Is Beausi Pa) | ene ent pe eee pt ee

You might also like