0% found this document useful (0 votes)
3 views18 pages

Python Notes 1

Python

Uploaded by

sasugoku90
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)
3 views18 pages

Python Notes 1

Python

Uploaded by

sasugoku90
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
Python: _y python {8 a powerful open Swuree, nigh-level, Objeck - oriented programming languge im Aaa > tt ae Simple aasy- i the perfec ingine for Someone tytrying to learn Computer Programming for tne eae time > Created oy Giitaig Van Roseum § First reloosed! to -use Ssynton 3 raking Why python 2 » it works on ifherwnt platforms (\hindows, Mac, Unux, Raspberry pi &c) tt has a Simple Syntax Similar to English languoge * Syntax thot allows ckvelepens to Worite Programs with fewer Unes than Some other Pragramming > Cosy to use: it requires, less Coce to Compete 4 Basic tasks y ' * Cosy -to-Yead ; more clearby defines! 7 Gasy to maintain; Because af its Botox Git ay Object-Orented: we car easily Cuars (use and objects): ks Clase mocel Supports Ocvanced such 0 Powmorphis , OPeralor Overto notions q mulkide inhentance ° (user have freedom +? quan 1 Copy, distribute, Gludy 1 Change O° improve, the Sohftoan’) understanding the mystouious Syst) > Frees + Readable ( > Pooorfl 5 Bulomatic. memory managment [two crowed for memory allocation vefenence counting & gexeoge collection ) ~ Large Standard Ulany sne Ubrory 12 veny portable and Cross~ Platform Compatible on UNIX, Windows g allow interactive _ Intexackve Mode which gesting and debugging of Snippets ob Cocle. ~» Portable» PPPLICATIONG OF PYTONY -+ ideally Salted Rr rapid Prototyping oh, Complex Opplications vit tg also used "Glue language” for Connetinc up > Pytnon ie offen usec do build & deploy web applicatc & web AAs Pytnon ip King Used in) Tnany diverse ‘apphicattons a | facluding ° Goxtp ing a + Rapid protohypi + web applicatins «Web eee + Game development » Gor Programs * Database applications w Gigkem adminatraction Geckend «web development , Data analysis , A, Sciectifie Cempatine aloo Used python to ames & desktop —r many Aevelopers have build produchudhy tools, Gq apps . Creating oi Saving and = a Program (Script mode ). 1. Open tne python Shell. gq. aick on “New File” under 3g. On Clicking » a new window will come: AP Type the progam Ds acho 5. Bove the file ee G- To run the Code (Fs) : “ F Now Run module cor) Fe a file menu. . Ex, 210 J é S y=a20 Bott Has ike merry Sur 2 Gly ob syst vonked ae ~ eq] eT ate 8 190 _—_ [pigorithen ond Ravckost | "eg alerts: ts, Sep by- Step peepee di 8) eas Algorithrn ikea 1. tort, a. take two Numbus (A and), (Py o AP Aa ABYP cee sia terercd Sciok > 3 ne ey ri eok iby Fan bog * Clear Steps © + Finite (muse Crd) etbrL Symbol O-oval NF stat « Skasit Zod az eetenes. Q £5 Diamond > Proeow ©) wolis! ¢ Lf PNR situa 2 Nain ee x cx: eke | IBO) suiienndy studs) Variables § Date: Typis- tne fofprrabien « Vasiable ; an Used to Store tho! holdg — Gr, ik ig like a ‘box with a name a value. x Oslo. lahavi oa Rules; smust Gtaut with a letes Cor ~ © Gonnok Stal esitn a numbed Cor) (urome) * no apace (my Name % > mmy-name) + Cor- Sensitive (age + Age) soy Nanias-t0 = "Pele! ae Vint s Integer —» Whole, qurbey © & Boolean bod ACHE) 2 OG=R\ ig-pasoed > We : “g. Lisk Lui)? collection % Float -» Decimal number : (ordesed, chanegsb? mares *[90)10Ks] Price = 94-99, | e Bbring (ste) Terk character 6. Tuple Chiple) -sordered Name = "lahor" Point= (10,209 Buk nok me = “Lahori : Chanqeble 4. Complex number OF Se > Unique, values Biauk nok = OF return ary eons swe with \DENTIFIERS os tk ta Ane name” qren to ,vaniable , function, ass (or) Objeck: it te the name used, _ Identigy Son ppiday Suxoqe = — oa. a he? os 2 — Meme ‘e ee el AUB bed todd, le ae. pass © Rates mask atonk ath, ge. oF to 2 Cannot» stark a ComMMENTS: | SO oar ait used” dy)! actes usthin 2 Sept fer seta human §, not for tre Comupten. ae Program yer igi &imore neha naa ites Aiialt to reod tk & Non - ~Preastable line 1 % Progra Used do Explain hu Code. Why te @ improve Cade Yexdobity = Heb others understand Your cade, > Oseul for ddngging, > Explain logic fo Sams: Types 4 Commer r | Single-Line, Ce ca ye Start with # Use tiple Quotes ("a "" enw Tent ip mtiline Comment Bo te ea lO +H Storing Volar Jara Steuctuges _ Date Structures i oe cay be Stoves ant Btrudures. ee ALGORITHMS: oe iF about now to ‘ied “cifjeunt “problems, hfe joy Stasching through § manipulating chte re | I moUS ylories a val eP < Combination of Data Orudure + Blgoritheo “~Ciret 401044 1 sobs he Ati poisbeaey Pye oak “ os 92 ance am ead» lle DSP i ee clean = > allows use do foxprovt on wih pyre ig " yomk Cote doable Synte prohurs- Sobing wore ace > Batter Onde stand My, mares “+ tk hulp th Ao Wann Complex! ~> Pyfem Ip totdety unl in DS. 4) PLAORITHM.: athe usorking with dol ig & Solving Uke. Qorting, Searching € ~ x Gnear Search oe - Binary Search, * Bubble. Sort. oy 3 Seleckien Sort » eon axe the bult-%n dale Qtruckure Qewves 08 a. Aynaeite array.) Lane Orclered ‘mutable 2 can Genbein Elercunts a het typés th urea to Store ae Shares. Creeshing ENG eset Usk Guaked age ie brackets py: oe te Ua AE Senoky Us “. ye li2s, oe ae. voles 4 z > Cy saa dN rast yrs ust "Metirods * lia cantina Several Bulle. Bicone ‘fs 3s)40 Fajen Conman Opantion Che pried, Sving i ee ees st Sorl ten wa fo = [912,741 ae Wiel see sat Crop HF 68010 Sa Cai. na) ae os wk wylosk Careniphe Of array = C3,10,4.4,.00 8) min val = ays annoy Ferd fre 2 my omeig: if 1< minVob minVal =i print (‘Lowat value (', minVal) the Siete & fosk but ib date, t brig 2roust wil taken to run... “TMe Compuesty | a oa eee fro Sw 0” mei pg ? tne opt Oe i bot Ae es rel Bg: O nately ' ‘ sbnckead of meabtng we Wtosy ne Ae - Bt alata holier ae Craton ie te bewsme: g-O Netien Coon CREWS CA pe) : -O wb svtbes ruc’ Work ~ cass Pepa an Aes 3 ‘ oe labs A Paenrce a OW). » Rindteae'd gu CPa shes oe vegarthm te & Very forte 7 A dP Coot ig " pe | neonttinmte ue Dreeaptotu. b Bin e sani ak | Beatrice Sheu ota) | | Sarena Vey Slows, PMCS acai Pabalady 1 O(1) = Cone tant Hime os Qxr = [10,920,207] i caret ee vegas — Hoput Size. accensing | eR Tay ioe. On Zumenct | < Srongl a Q Ours es steep PB os a95 Time Frereones Cneanty oon . Soy “Time ! 1. Obeg ” rn) ¥ Lo. goritnmte Jenn binary Search. del binarg- Search (arr, korget): tbe rigne =), ten(arr)=1 mobile Lebt c= regnt: enid = Hebe + ¥fqob) Iz. Sh, clmiad = = target: return mid eu, ary Lmid] < target: pelt emid ty i acTqnoré ‘constants 3 us Kar sage rs Stack Black: tg a Unear PS thak follows tre laste Ficch-Oor (UFO) Pripciple. cick %E 18 Uke Cookele - we can ory adc © Semove cookie. form the top. 7 last Blement Added i tu bist Ore to Wt fernoved. vf Bostic Openation ; oe # Push: add 0 new Slement on ‘ne, Stk. # Pop! Remove & velurms tre t0p Zlernent Pers ue Stack . ? om Peek. Returs th Aop Uast) 2lsment * TeEmply: Checks if the Brack ‘© Ecophy. BRR) Pind)! Drecno » 1h Slammers - an be linked Get. > Stacke (or) fmpumnted by using arrays —> Te Used to implement undo mechanisms, to Yerert to Prewous Saks, to Guat Al for dope —dirck Seavey fo + ; Peers wu beuctrauerng, ey thfle (pyhuen Urk Con fe Ue as Stacks, Crnicla a clecheeted Shack Clas provides foetten Encapusutation @ ackhtven al pune enatity. Me s,\¢ ,\2, als, 9/3 | Implement Gates — Using Mits/orrai Because \ Clarins. addren tile Unie Uh Te & Ceafen to implant and, Uncinitony Using anaxs to. fmplemant Statks V Les. ade Mon «nn, Unked we A tuis reason tg Sarieet Baxeien + us , beaded inven aigent sh baad ay a Wisp ot tov ase dy): westhig Lotssi beaks: r Deve Qhucaes: tf @ a Unear cata Structure that follows Best — In fick - Dut (ELPO) principle Cx:*line in ad bank + First posson Erteus- fiest -povton Leaves . leaves - Opnatisn : Flo Enque - Add Stement to rear Enter E40) s ae Cito ,20,30, 40} Deqyueue - Remove Element from Bi a Peek - Se Pont Bemat \suply — Check ‘f Senpty. Queues > using arrays or Uinked Usk Ex: offee printes, OFdex pro to ovat cessing ber e-tideet , algoritnms for Bretn—dist Sexch,

You might also like