0% found this document useful (0 votes)
5 views20 pages

Python Basics

The document discusses various programming concepts including algorithms, data types, and memory management in programming languages like Python and C++. It covers procedural and object-oriented programming, memory allocation, and the use of different data structures such as arrays and sets. Additionally, it highlights the importance of syntax and semantics in programming languages.
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)
5 views20 pages

Python Basics

The document discusses various programming concepts including algorithms, data types, and memory management in programming languages like Python and C++. It covers procedural and object-oriented programming, memory allocation, and the use of different data structures such as arrays and sets. Additionally, it highlights the importance of syntax and semantics in programming languages.
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
| | r #@) Syntax recone | . = @M [| “@) semantics {7 : Acceraniy ts . conceats Lou Lev ‘ hy puter to filo. % Algocttihm : Finite set of instructions written for Criterta's 4+ Input . dettatke seffecktve -*@Time complestty | 2+ oukpuk a. finite be Spat enpleaity — * Program + Exprsssing — alga into ogrammigg syntax | Language as per if 2 ana semanti L val_netontaci_(pasenl.¢)—__—} Ws y yadda * @_dbject ortented ( Java , C++) # pithor ston of epP and POP i i : : i + Prohiem is viewed as ~ collection of functtons | proced uri Gy: ada) 9 sung | orocedures | functfons | —_ mut) af —_— dfvia i * fnrerprebers, assem bless, (naders, [fnten. eo | 2% Pencenurai Orientep * 7 L Booode em / = Pomphasis | focus 6 on kiting pricedure function. matin () 4 €9sy to trouble Snoob 4 2 easy to extand PSone sco comeurety | fiinctfons {procedures =—®. ts advantage. ore () = more time _complestts nest time? er + * oprecr ORIENTED * display Q #00 a nared data Sn get_currupted C a e > oe bei © Los ek | © £ 4 func 2 | fu | ha ¢ © ¢ ‘ sky classe. > object NO memory is allocated = ee jo vyouva —coler eatiog running sleeping) a Sy |) => actton: ao : fel alee jane i = funcifons ¢ associated with the object 4. Platform independence 2 Portanle | 8 Poredural and ohject Oriented _execumion OF Pyruon —PaoGAara* Beco a —— : Sa re iar, Fed cone ome edehSton =i fle oye | pytns python compiler © virtual Byte codes {ev} tndependent ) Ss raverpreter ro coco +0 machine code F® Hoppons automatically at roubin J» py objects on python ts storect on Hean memory t4 part of matn_memor tf t Jobtect specter allocator allocator ayskem memory allocate) BAM Hee memory, * Runs sipiwer © Runs foster : “2 Chas do while, wibfle 2 for 100 2 Python hos whtle &-for Loop @ varlohle tn for loop cio. r 2 Vartabies fn for loop auto. __guto fncrement. in. tb S PVM dees memory allocation * Monua 4 (mallec(),calloct) function - is Qs Nio_garboge collection oA ¥ a © one dimensional btise dimensional —® Oni, one dfmensfonal array array supper ted Supported A Muiti- dimensional_arra Nprary numpy ibrar s Array fndex ts loth positive negative, Negative frde. end feted not ti extant falig madrt~f. operation | © Semicon (;) tndteates end oF 4 Semicolon (3) fs expreacton statement pecatar delete /removo- a [2] count count —_¢dunis Rosa Rea ROB 1 Abe Gc 0 tee object tokoztgencration 0 ==? removes older generation f generation 4 > generation 2 5G depending on‘ threshold’ 2 & how coany Himes Ge can o Exomgle : (1) Threshold —> 40 (a) piiocation —> 15 fica-p 74GC run ic _¢? (2) Deailincabon ——> J co Co pa ar ee 5. Ss yy ST ee (8) Allocation —> 15 If B-D >.T :GC run. er een — ee (2) Dealiocation —> EGC canbe marie te run manually - 2 tntervals J ent interval ini —. —. _— (documentatign string). * Vapiapies IN Pyrann * Vasiesles si —obf t ys. 2. o Type of memory Stored rariahle /maemory— F=> int: foteper [= Picat ? fraction I? atetng : alana numer! [= complex + complex number o pom pe mae | See ee ie? a data type and make tt tp hena as a buflt fn data ty ==A Mapoing (Map) Now Tyee = = + Object does not contato value = Example: = NULL = In) = 2 values are ein c++ int {6 2/4 byves ve Limit seicientittc notatio 2-5 x10" 254 : -s=t_(omples datatype 2243} Example: 241 = compa (2.8) reat“ —Simag : bi4+5} cza+n peta (c exe pecimn A SSS B= Anagy + Starts with On’ or OB” Example: Obi! = Oerar +» Starts with Oo" 7 Son zero Eiomple? Ooi AB Hexanecimal Starts with Ox’ or ‘Dx’ sete Senore : sDecimal no ——> (_y,, $952 * Binory np ——> (_)g > in 08 4 Pr octatiend ams (ade > poe s 7 # Hexadecimal ——> (_)ig —> 5, 0409, A ine aopaw Te pores ‘Youva we 44 A a ay ol4 2 AL 4 a 1 [ Pematoder 2 | oe ong Seseenas pal eeeseee ° see Oo (15)—>(444 4 (23)—rl4o14 do ® tinocy —To__neclmal, Example; 10414 aug +09 2 +ixg tap et dat sie +O+4+ord 22 B pectmal To Octal — eee. a |i stags [a 2 els | oO (5 )io => (47) welay 24 é fener oa. o (34)io ———> (22 )ia NOTE In hexadectmal 4 — bisary ——> hevadermal o—o 4—— 4 ==.8. 12 —>c 16-18 1—1 5—> 5 qa— 4 B— Dd 2a 6— 6 Jo A IW E a> 4 11 11> 8 IBF 03+0x8 —> hexadectmal — n=fnt (oi). paint (" pectmal:",0) Olp s 45. m= fot (02) print (“pectmal: "m) ojp 2 45 p= fot (na) prtor (“Decimals ".o. ojp $4 oB=U n= bin (ni) ofp: s pint (Biogry = a > Opiiit _ — m=z oct (n2)- ce ) _print{" Octat=", on) _——>_Doid ! er = hex(n3) ortor (" Hexadecimal + —> 0x8 ica s False «true + brup 2: =e 9fel = a=10 b=20 P(acb)? Soren gpace a 2 ortnt (Heli) gonty _Looaifon }“Stette (eted) tx: fio, a an 40} ) print (x) 7 Array te _madule a | o ems | le Co Pus 6 lection of elements (mixed dara tye non_continubus) Go cxampe : x= 110,205, 'G"," ganda] dysoni {grows at-run tone} | T prior La i i so on for i in x? se —— . 25 orfat (1) —-— atic(aize doesnt change run time) © Dynamic Py F i s 3 yA e'lcinent scone tnd’ 6 emis San aa [= data structures print (str(p:al) Start << \vends:0 int Cstrf-4) printiabe) ertot (ane fo) ) S tor lobe lii3}) s obo lp] = 10-5 4 eft) #307 F print (abe pet EC A GE print Ct) mele 20, 0,40, 15) 13 SP sola: io 20 o 40 16 bytesCoie) ‘3 jets) 244 eleta1:44_} not replaced for inx’ — —. for_{ tn x png ptf) print iy. wojp £19 207 OHO NE Ly Poip BR 41 0 40 1 1 = =. a = @ ture _ ee tpi = (19, -20, -20-5 a". Gee") [| eine Cup) 10 ao ec om zs ot (tpi o}) => 10 ms print (tpaf-21) ——» A nove { Lstite-rend | —_ tpifo]= 15 ——» ERROR ond write f —_ lot (tpt) = > S fanae a _- Range cata _typ foc 1 fn EPO less then _max_\imit a 9 int(i) 4 . : — p + + ofp: 20 89 84 26 38 (2 tess than 40) a Ists Uist Crange (403) ——> Lat = Lo, print (ist) * SETs * 6 © A-set te an unordered collection of elements where duplicates are oot and_set_nes are mod yan » | _@ 6: fio .20, 20, in,208 Arty peat (s) ———> _ap:_ {20.10.20} -@ conf aos ("weno") + varfenrtn (on) pip: Siw te'i'to'} i OR. on ane a i ——* note: winen tt comes te sets i s: [10.20.20 , 1D, 20 : which are unordered a print (sfo}) > 40.9 | we connor retrieve tne €\ements— + print (sf0297) ———> tn a0) __|__ using. siietngy fndextnp_operation. seen 0) fans tit alle ete 6 qin (s)__————— 10, 50,2060 20 i srempve (50) . print (s)_ ————>_ 102.0, 60 1 print (a peel 3) prink (d+heysty) ——S 10 2G fa) print (d-vawwesey) ——> face’ 'Pece? ‘ppce'} 5) deliol='Gec ponpa’ _prfint Cafipl) ———> 'Gec Ponpa * * Lite Reis in PyTHON # @ tnteper ttteral sis —"@ oct ttreral —>@en7 @ Float likerg) ——>) x= 1565 © Bin literal — OB wit Boolean ifterat true — 4 String Literal B=" This t Si =" This t ———print (si) _ This_t: ry a new {ine char | @ \ Nertical ta EQ: horizontal tab eG Nc enter (cursor on new Line) @ Joins_strtng ~ Deveaminine Data Types * + xs © Dat as a lass ‘int! s conéidered a6 a class yams : prfot CtypeCy)) ——> Si ='Aharot’ ___print (sif01) B 3: Functtonuntetea tae of tater print (sif01, fsunpert}) —> True that constitutes on. Hi ociot (sif1}-feupperC)) > Fass =— bs |. foto ~> True Ident? tiers LPATTEEPTR RR RR eeedeaaadccccak

You might also like