Está en la página 1de 31
UNIT-IT © Explain about Whitey and feabures wf python. => Python vs a general pexpose Interpreted, Inter acklve, oe oulented and Wigh lovel programming Language. jHistoty ap Python wos developed by Gutde van Rossum bo che [year Of 1985-1990, at the Naxtonal Resoasreh Dratibute For Imathomater and computer Suionto th te Netherlands . sf Python dactved from many otro languages Including Aigo!- 68, émalltall, and Unix Shalt. “Ape, Modula -3, C044 yeThe name. Python got Psom Bec comedg. soulor ! jum the deventtes "Monty pythons Flychg | Gaus". ae Guido Van Roun wos a pan op the comedy pe 8p he decided to Soleck the unique name 40 he Lenogo as | python’, i | |Gagkwus | (9) Free and open Source | | (if) High level peogramnating language | MD Simple and easy (iv) Portable oy (v) objock oxtented programming longing, vt) Embeddod with ¢ con C+ (yit) Rtch See &6 qunttionalily available (uinty Sok op buile-tn dake tyPes Grd Chaysty Constauiels “ * (x) Easy to learn () Easy to mointato | lewelo dovelppemante de trane developement : zo Machine loarning ond ag ( Adifica) Dneelligents) [he Paka Selonta, arc vigualizalton 5. Desktop Giver (oraaphical peor’ Tnikerperer) (6+ web steaping applta.tion : e Bushee Apptcation ge Audio and Video appltcaKtons ("- CAD applecations ( Computes Atced Dostgn) [toe Embedded Applicatten, iy ” (V) obfoct petented progeamming language (vi) Embaddod with ¢ con ¢+4 (yi) Rich got Of -qunebenalily avollable ni (vit) Sok op budlt-t data types and Crt | Onstaucls (%) Easy to learn &%) Basy.to matntalp Appltcations 06 python: | leWelo davelppement | DeGrame developerent Be Mathino learning and ar ( Adifica) Inkelligents) jhe Data Selene and Vicualizaten |B» Desktop iv (oraphtca) Ysox Tnkerece) |b» Web Straping apptta tien Me gb ee. Appt Cation | e Audio and video appltcabton s * CAD applteatione ( cary pukoy |Io= Embedded Pree Aided Dovtgn) | Enplain on ( bytecod Joxavtne. and seelpt mode us thon - Enplain the ‘nlesautve and Scadpt mode und fh Py z Puthon “Intespretes “s bon is tontidered ag Interproted language. "Tho tntesproten Protesser Uo code Une by Uine-Tr ewabor J. bytecode- sp The byte coda & more ttansperable betweon Operating Systorm than machine code, this helps python bo tens plat teu. sb The Interpreter hog roany advankoges women Comparod to Lomptlor, tho foals 65 Intospeotor ane ag follows: > Translares progam pnp Statomont ak a Hime ~> TE toker lose me to analyz the Sourte tod. > Moro memouy obbieeney “> Debugging tt onsy, > No Intownodfate object todo te gonosated. > Read ond Enccutes the Pytnon ope. > "oss" te tt called prompk, conten Indtcatos that’ the tnteepantey to swody © proterg. % Thee axe tuo WO tased the ents C1) Dikoracktve med (HD Scetpe modo. = am cy peargeine Mo | A ammediate suse 4 ° | ap Asnow Lines UP evaluated both tn Paak and yp, ‘te ed pang bw Ss 14) 2 >» | ok Ty we type I+! on tho twkeepretay 4 ] Ammediate agsult "2" will be dtsplayed by tntarpes ae Propet Indentation i Acquined the code on tr tntope.tes shot. ” 7 (he) SSIS Io: ) | patnt (* How ane you 2”) How ana you? | >»> | Th Above | Code tho. petnt! statemunt “Indonted Atos that Just htt entos to. bnbodtuvo H Une> Astor this ° | Output Lilt bo played. Cm) geupe Inecles thts & also cated! aa nowmal redo «tho pation’ cermnn fare stored th a -ptle and tho gle 0 saved uaa) oe prtenstay «Py (0) Stlename« py kelyyne python progiam tp seapt modo using following eps: ‘ Step 12 Open python Shell by areking che python Lbe _ CTrtayated Pevelopemone Ervsvonment) step 2: on file mon click Bn Nowftle aption. Sep 3s bitve Suitable yile name with extension «Py ( Ex’: test’ + py) iskep a ie Wilk gok Opened and bre tyre. tho programmes ( ' : | eee Paint ("Hello yionds , this ts my 4out python pagan) Pant C" now adcling two number and digplouy) “tno. surh) pant (94-3) mee Step 5 + New wun the coco by :elfering on Run. on Mon hoo For uming the Sept Ako Luo, Fo key. Stop 6 : The oubput WI be Absplayed on the python cho Hello -Mends, This & my fiut python progam. Now adding pwo numb and dtsplayehg the seu . 5 ASS. eas =>Paogrammneng errors AO Caltod buy, Protors op tracking the bugs and clear thom ty, obniggtng- ye Tinco Ieinds op emote ca” DLL Uh a 8) suntan BRA" geSyntam—_ cLauckure op PROG Ond gules about (hak Seuckwy “5 Python can pny enooute 2 Pangea ty the ¢ ty potmack jothonwise the ttorperton displays an & Mowsage and quik the programe (em — (oa) Ee legal, but 2) ts a synten be UD Bune Baee “> This type og crnos does nok appear until attr pzogiam has dtasted sunring “This eras alo (a lencepttons beceuse trey Indicate thot enception. hopponod « iin'Somante Exot! => Tf demantic Exot oecters En the progam , itt Jun successpuly buk the System does not genorale lenans momages, but wt not do the vight theng- do sometheng olse- C/ Erplain aur values and daja typer of python. ge Type dotorntines the letnd 6% Vabuo and : dotermtnos , how the Volue can ho used+ AU data Value tp python aro entaptulaked th xolavant objotk Classes. Dota type fs the type o% the data, thatane ove uith fh Te pepam. x Python has five Standard } Bilk-th data types Are as fotlows: 4. None type _ Null volo 2. Numeric typog Integer : 1934, -39 Heat =: |-984j0e-4 ocka) © 93, 9134. Hex + ont39, OXIBFA Compkn 2445, 35, hed+ 95S Boolkan —: ay3, None te a Spectal constant > Python str Bb a Null value > None (s hot te domo ag fale > Nono fe not 6 (ze). None bs not an empty Stang. > Comparing None to anything other than no Always xokven False- + Th Jova. it ts called as " Nut” Obeck- & Dn python te te called as “None” dpjetk > hos Us Own dakatype ( NenoTyre) > AL Vontables whore Value (x Nono a td each othor a 8 trot, None 12 te only null value. Fol leviample Shows the None data type encoutien, >>> type (Nono) SS None == Fake False > None == 0 False p> Nona == 2 Fale >>> None = = None ‘Tue SS @ = None **>_Q = = None Tue SSS b = None > Q==b TA »s> [| Mumete Types. |e’ Antege, <> Trkeers aw whole numbone Whtasue |b Raguiaa antoges dectmal potnt- ‘they can be to |G otal Utrera iGalee Ly Hexadecimal: Uterale > Integow have uunttmtted ¢tzo tn ' pee y Liberals Python. Reguton ‘ntogers :- > Nowmal integer mumbo (re) Sssaq =4993 SS b = -138 »>e = 4 Octat teterq ls bage 8)! St Indicate an octal NU? U2 tiny Do fon OO ( x01 followed by etther a lowerenss case (otter '0') ()-e) dd t= O05 Ss patent () 5 >» Pe) Hexadoctroal Ubesals (base 16): > riteate hexaclectmal Literals, Use the | ‘ox! (8) ‘Oa! (zoro and uppercaze c0%) Lowcitas \x") fe) SSS her var = OX9A SSS Patnt Cher Maa) : fey i) SS, Bh : ward Utes (base 2): 2 T Indteote benory Ukerals, Luce th Put! ‘oB' & ‘Ob! (zp ond Upper case fay) Lowond a e) tyes bin = Obl >> palnt (btn) Is »> Enemies yor Convento tyegess to thats sting (4) Convert tntega 6 to ib outas Literal :. >>> ork lb) \ Dob! >> (2) convere trueger 154 te Uy hovadenrna) Litera) :. >>> box (151) \ Dxqal » | | 0D corner tntegos 15 to Ue btraw bees: | >>> bin (15) ‘opm’? > > Floods oe walben asith a dackmal perk Fob Genxagatos the Inkegr “pom the -yotkionad puro. > Te abo to wattten th suante notaston- ‘eo! stgntiter the loth power >> 3-803 3300-0 >> 525e2 5250-0 dD ager 1290-0 225} complex numbers Scomplox number ate pabl Ob Aval ard ange Numbo - > w= ytot SS y= sta MS Zz =MTY Aes >>» Patne (2) = (4455) a >> I. To convert Yes to Q float >>> Floak (15) 15:0 » 2+ TD convert \n' to a Platn tnkeges of SSD In— (15-2) Is , >> 3. 10 comet Sor! to G& Corpo numles + SSS comptert (15) (15 40)) SS complet (18-29 (\s-2 + 03) ». Boolean Raratype « => Boolean ts a data type, having wo Values doroted by Tee ord Fale. Ss paint (2 = =2) yaw >>> Paint (243) TAU >>> Ts] Sequences" => Sequences [3 the Qonorte term efor an Oukerad Sek Oh CloMOnts- There ara Several eypor of sSaguaves f python given belsw eM byte de byteannay & te se tuple 4 Aange, Bel] Sings s . [eoltection 6h Chose ctor a => Stalngs th python ase EdontHted g, Leot t Chorcotort sprapentec fo the cua > \Q - 2 tndecakee the Hing 7 opercrkoy => yy! - Te Indieater the hin Oper akor. DS SU WRB CE T yea! SSS pate (sty) ESE T yean, >The byte Sate type tie quoup Ob la humbos [Eko an Ova. 3 Te ranging from 9 bo o55, It cannot stl mogauave. humbons. Synkooe bytes (T source entoditg [qu > thems = Tro, 26,30, 4.0, 807 Sas byter (Ttems) >> Pine (a (oJ) C8 10 SS pane (a (23) DYN 20 7 mt Gn eo) Bie wy: @ Dt ts Same A8 bytes data type, but data type array cannot be modefeed , whow as the pyte cvay dak EYPC con be modksted 1 | ypuaet > bybeosray( Lsounte [, encoding [, emotil) >>> OL= byteamray ( b" py then Bytos") >>> Palak (a) byte crnay ( b' python Bytos /) > »a= byteanay i ey) > Pate Ln) byte amar ( bo \n') »»> ; Lu] gets : She dotatype St, Which a collection typo. Te upntaing an unordered collection of Unique and Immutobe opjeub- Sat doos nok have dupltaate elomen SSD rwmbo = See (C1 ot Whi ty 15D) D> numb Fy, Yo) GBP » . Frozen data type * Re Ne “Ly Te Bb game as gob, bak Ue Clements bo modiftable, whom ebements Db (ou, Imoclested- Say ge Proaansol ("yz") dsp paint (£5) frogonoe (f° 2! 1a! td) TE] Mapping (pictfonerw) * => Python’ AteMomnies 0x2 kethd 08 hash types Plottonanics Oe enclosed by Cty bu and values con be asstgnad and anced sty bvaws [F. dsp dice =f soseatce [! one d= " Stas one” - fF. wo" dp deve [2 ys patne (dice C'one’ J) Fisk one Sys pane (dtc [2}) ‘ Botan “HO Ssietfonarin aco puk of Orda” : ar cimpty unordorwd. q) 3-4 Uist (4. ; eo > A list tontaint ttoms goparated by commas and entlowcd within aqua brackets £7. > phe ae the mest VeMaltle of pythent tompeund dara types. = The Values Croce ty a Lat can bo accocrd turing SUice Dpeiaros [J and (+d => The Indexer gtatttha fiom 0 end ub -I- >>> et =[' ese! los jum year’, | | >> ontine = C use, ' compuker’ J D> Pitre Citse) Ctese', toa’) tq year’, o1as') >>> Paine (1tse Toy) &seJ D> patne (tse Prag) ese yea) >> pint (\hee 4 smitse ) \ ; ‘ \ ' Cesetiaats yeas 2622) NEG Ncompuker 7 L ay eres Fy = 5 wi Emplain details apsut Vartables :. ‘'Y Vaxiable :- SA Voxtable Ba Aesorved mona bg Store Values. => Vantable i an entity to Ue Ping, Can arstgn some \luos- Gy awe ge The \Voalable count to whlch Value Io lng This Value ts displaced by Pascing the Voatable 5, _|Patnie Stakement- >>> count = 10 >>> Patt (count) lo The Voxgable 1 Ue tnaty SS Wulte= Joo ste ee Sos Ptnt Ceoune) © then a with the valu lo©0 he CRED Ata aka Astorment: . stata > The osstgnmont statements cxoatos nolo Vastalbles and then touespondihg value can be axtghed to fe D> Use aBsegnmant Opexcck OK “240 al at Sm F > ry ipo F aus can be asvtgnad ko waits ((e) vesiobe >> A=I0 >» b=20 dsc = * Ughe! ' >ddPaink (a) Thue Vortables aro lo Aurgnod with differen >> patné (b) Valuos- 4 2d ds pane Cc) Legh oo Empatn details abou Enprsstons » SEnpowton ta combination 56 Values, vantabls and —eperatos > Value Uv centtdowdas an onpeesseoy >a =10 >>> A420 30 P>> 4B Y ty. Sthe four statement GB cxtgnmant srodemanr DSTh2 seurd Gotemrb 2% Onpzonton > tho Wibepwter ovatuater Eno enproeton ond display the rsult. )) Explaub the tuple Lued © Python: => Tuple fs Q Sequonte © &, ‘tems ob any > Syntactically tuple ts 0 eomna rag voluessyy petal > conventionally tuple one enlna Ute Pasentnosts ( >” > Tuples can be thovght bh ar oad: 4 > Python has a very powerbul Lupe arta, Peakure thae ablows a tuple Bb VOMAbIe pH 4, of an cumégnment td be aytgned Valuer: tug, lon the Leght bp te “re ae) Enomple:- sy lt , Tuapte arsignnernt © ae o SSS Cay bys t toy 209-—> apt >. Pane (a) _ Fa Nouablet Io é | °SSS (ob) = (bay og ths ASD Patna) bs tuple by | | A )) genplan, Ue Pancedente operators usa] th pyttin 0 2 pporabos axe how ypouoweng axe at gal pytion enproestons. oth, BRL, BERD > Heed + operator & for ockbtren , ¢- mubtip Ut cotton lad xe - enporontiabon, > when rose than one Oper. APPA Uh an enproction lime order tg evaluation dopende on the Autos 06 Pracodenc- > python goltows tna gamo Pietachree and ean bosticeds to Hofer any cnprossith bp €verluake B® tRa Srolee YOU WaK, ules por bbs mathematical operator lat ta thematics Ides. > The Qteonyms "PEMpAs” I a Useful woy E> samombor |e bides 05 cporations. 4. Pos Porenthores Wave te Wighest Prececlanea and cun be used’ to force an Cupreeston to cvatuase. WD tho Order Yor Want « Sine, enpieutens 6 pasonthoses axe gost ‘Le llo-5) Bs. Craliake f DBE os Enponentiation has tho nowt ™ | D owes bb & 3. Mpas :.Mubbpltealion and Diveston jy, Procodonce, vohich ts btghes thay, A ; and Subbeotion , which abo bay, Same precodaunte- 5 24 9m4 Yyoolds 14 ratio thay » he operators wirh tie Some procedoureo deo oy, loft to.akght- go, tn tho empecsOn 3-241 ity oy As gubvaceton te porpounod fist and tion 04, 0)) Enplaty detols about: commands. > wmmands ae the kind Of dtatemoerle that Wattlen tn The program -fox tio Puspoe nie tie pwogiam. > By tho tonmnond stakormonts it ts i‘ tod What they enactly tho progam bd > Tn python, (28 bash & used tp yyaling t Coromone ee U< at pntands up to to nowsitne Character , 2 python trkosparter “gnores Corman or cxampe H7h’ te corment Une Pant (" 3 love mY county’) 3 we have tre commana tha ontond muttiple Lines, pre way v6 deing Ye fs t we hash (4t) o> the begenning ly, eath Uno. Fox example, This i thanothar excunpe + 0} conmmont Stakemont- Some another coremonts used tn the Python aro Os 40)lowss : WD Blank whe = A Une toniairing only widte , Spare, porsibly ith a comment , Ls known ar a blank Lenes (11) gemb colon 3) ‘! De abiows on on the single lene grven thar oltre: “Ceakomone sbarts a ae Now coda bio. ee @xamplo D> A=l;, b=2; C=3 7 bum=atbte) b >>> Pag ty Waite the Progam to ona: tho Values & typ Ua : Tho exchange BH valuas OS tuo vob ae type 65 protemtng : gt 1D Exchange bee Valuas by tuo Vostoubles WiItASiue wing 4, W Enchange tie Voluos 06 two Vattables byyeing Suncten, LD) program withouk using fundien: Algoxtnm + | SHEP 1: Start Step 2: Rood tw. Values Ob a and b Sip 3: Stow the Werle 06 adding a ard b ty the quut Vaxiotblo (a) Step Yt Subtat HR b Rom tho a and Sow tho sock us bh, gkop. & ., Then.» Subbbrack the @ fom the band ‘ GEOR, CHO Am hh ae? 6 o> PAnE tho ewapped Vatyor f + $kOP au aeint (lopu “enter Value 55 a) petne (fnpue ("enkor wwe’ 05° b 3") a= tb © wt ol * b=a-b ° Q =a-b Pane ("oi x", a, "bbs", bd wa N iad pa dase acto b= 5 \ Enkor Volue 0p a: 10 azarb \ Slots Jae By Vole DB obs 1s / | Se tits bu lo baa-b ‘ umd" i =25-15 \ e : b=9 \Flow chaxt : (Geott) Now Q=25 b=10 | . ‘ QA=a-b ‘| : s * Peder Ob = 25-10 \ » » [RE1s) ao sy Riad and / Reet tb axis | : bat0. (4D Pwogiam by using function :. Algoetthm :- Step | 3 Shae Sop 2: Peclare Vartables a, 'b ang Read tig , | SP 3s Coll the function Boapla,b) My Sep Yt The gunetfon perpoums to oun; 9 t=a ty, A=b bet , SOP > padnt snapped numbow ase » an Seep 6: Stop Flow: chave : progam. Ghost A= tnt (Input enter voluossa:# belie. (Input (“ontor valusosh:* ke : E= eval (Snpurl enter cov nm! =e ta L azb Lv _ Petre (“Astor Swap the rumba iber @ as pan (Aten ae Wi, shop (een Output: Enter Value 06 a: Be Aiees Swap the number b ub 12? " n ” a t .200. © PAGAM to Uroulate te Values of oy gap 1 t Soe “gop 2 + Read uippor'tunt "nt gap 8: Read’ n! clematis sing’ Loypard stote WA Ww Use ge re vt | sizp Ht POP put eath lemon, yuom lise end append to Use | Step BS patine Let | Step & ». Stop. |elme chose: Progsan :. ve wr N= 4nt (Anpuk ("enter number 5 Values. +) st 4. [J ) Sox f th vange (0,11): 2 >c= ne (fnpu ("enter tntegen,: ”)) Uist A-coppend (2), ithe Pade ( ("dua te cme Sty 4 dov0 th rane to;n/ 1): % = List 4. Poplo) Met 1 appand (91) Paine (tte 9) Lie) Output. Enter number 08 Valuns $9 Enter thtegors . ) Enter TMabegos : 9 Enter fntegos + 9 Creutating the otements 06 Wat Ly, 2,34 Caray 3,107 Cy, 2,37 0 program to tind dig i Lan between boo © point, i ya “ter ): sto sap 2» Rad, ,toeacn op 3° cornpute Oe Cede ord pastite paints tanta luting Jounula (mot [yo YI siep Wy + PALE Aiakante gop 5° stop bc diatanie = (em-m20* progam : mB! = eval ( PH (tena 1 and yl fer pont! sD) M0192 > eval tINpLE (Menker meand Ye point 23") a= ((nin m2) 4 tyreyodet $I URIS wn, abrane) Output * rnees x and yy fos point 1: Io Entos 9p ard yr for point 2 49,4 \ ’ cae [The Afstaneo Iokween Lio WO Poly jf, | 2+2360619 174 9979, |

También podría gustarte