0% found this document useful (0 votes)
70 views77 pages

Python Hand Written Notes.

The document provides an overview of Python programming, highlighting its features such as simplicity, readability, and versatility for various applications including web development and machine learning. It discusses Python's dynamic typing, memory management, and built-in functions, along with examples of basic syntax, variable usage, and control flow statements. Additionally, it covers arithmetic operators and type conversion in Python.

Uploaded by

siyogo2094
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)
70 views77 pages

Python Hand Written Notes.

The document provides an overview of Python programming, highlighting its features such as simplicity, readability, and versatility for various applications including web development and machine learning. It discusses Python's dynamic typing, memory management, and built-in functions, along with examples of basic syntax, variable usage, and control flow statements. Additionally, it covers arithmetic operators and type conversion in Python.

Uploaded by

siyogo2094
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
#2 COMPLETE PYTHON \ PROGRAMMING NOTES | e Stee 2 e s ~ HIMANI SAINI — ae = Date ... jo ~~ EyrHoN._PROGRAMIMING c- Into ducing Python - be: i — ea &_a_high- level genus = purpose and ves. it opular progr tng. tanga : 2 a! uate veh usd tn Gwe development, Machine learn. - -tag applied ete. eae ee Pytflon fuegrame ae Cd Smaller than the othes jin Hogrammin dong uages . — Puogrammers VU have to type Helatively less and the tadentation requirement of the Janguage makes tens a eadable at ihe time. + i> Voi Simple Syntax. 2 fasy to learn, t v oT Cv ~ a ooh ay | paint (“ Helto”) > = = General pusipose Janguage ( Simple yeh very powerful, 3 language) s Console Applfcatfon & Scripts iw C= f> Desktop Application : = [> Web Applicatfon ‘ ; * E> Game Development FE f Ly.\Machine: learning iden: learning. AL, Bf dala ek- = “4 P “t ot Z — Muttinaradigen Support = \ [= Pavcedural Style Programming _I?ke C - = sl “s L>. oofs ike Java, © g Functional Programming (tke Usk. f => Portable or Platform Independent = Puoqrams are typreally first compiled nto an Utatermedfate cod¥, then the code Pe yun Me interpseten . —>_ Dynamically Typed. nyna 4y---NP ~= 10 4 ys “qeeks™ 4 uv . ace “python J 7 This featuve %&_dffferent from Ctr b Tava. they ‘ ae stateally Typed i In python we don't have to specify the vatable PY i name. But _the disadvantage & fm this the type & asstaned | ° i v in the vun time" of the paogram , so there avd f paeg move chances of yun bme evror. — Automate Garbage Collectfon ‘ \t _medns when you 4 dynamically allocate memory So you don't have fo worry: to yealfstng — th?s memory . g u \ § => Popular Apolfeatfon Butlt tn Python FF ~— + Youtube y Nettlix',) Quora 2 Instagram , DoopBox x 4 =r__batat O tn thon — % A__funclon & a sek of fnstructfons' that take x some fnput Prom | diing..dose somehiwork on those - Date .... io ~~ a quametes and 2 J ieample = patel Couette”) pofot Welcome", “to, ee = aint ©) ee F pofot (“Hope qou—are enfe zy ae Output - Hello = ~ Weltome fo aE a = as Sy Hope you are safeytag Python. xX Tos endgA end and sep parameters fn paint : PP f 2 z = int (“ wWeleome”, end =" 2) ra paint (* fo GPa) Outpuk- Welcome to GPG = votre End parameter __oteates _ space and {ft tells » shoutd ae be printing after tks patating. - And tn sep pavantetet. when we haveY multiple = P—f input parameters we use sep to separate” them. — # f By defoult they ame separated by space. a o f CAMS REL Ah Per i eae putnt (“10", “out , "2023", Sep == "y EE Output -. 10-04-20a3 a => Nanfables fn Python = Nawable & a name that oO used fo. suefer to memory Jocaton. Python vayfable also known a+ -fiex_and® used to_hold value. ’ : Jn thon, we don't need bo specify the hype of Notable because Python t& a in flew language and i —__# {__smant enough to _qet vanfable type. ie | get_vontable typ +s E z fee» 5 xample patce = loo ” tax = (8 = ! °, s = t total - pailce + ostee + tax paint (total- putce) * & Output =o alts, aq How vantables wok 9 a = 4 “= 10 Uo]<~ * yee “geeks” qeeks |e~ f ‘ Zaid (go|—z € it we say wez a § When adolf 4 Nwx 4 bat TP w=: 30 Bol<— w : 4 aa OPocs 165 3 410) f. : y) geeks 4 putat 2) 36 / print (w) : 4 oO q a4 | ~~» ee Pathan Dynamically Type eee 5 a Bo m% +10 $ J putat (>) . nk: “geeks” U ya paint (>) ~ 10 ~ qeeks ~y 7 ~ 3 Note - using a_vaniable without assfaning fk cause error. ~ &q- paint (x) » oP- Name Exror : name ‘x' fs not assigned ~— ut) tn Python - 4 3 This functfon ‘u__used to take fn put fiom the user } t Example - name = ‘input (“Enter the name >") 8 ” psiink |" Welcome''+ name) t ole - Enter the name = Himanf Welcome Himanf Example - # Python program tor _additoa ' t | +t = fnput (" Enter Fiect Number :") 4s input (" Enter Second Number : sy m= fat (x) We int (y) Hes ney F Spat print ("dm vee) vy lvl aoe lyl e blew lel Typed) In Python ~ Outpul = Enter Pirsh Number we rom string . Is d Type & a _bullh-in_function that Hells se h0 wherever we have to A you data lupe of a “vavfable or a value. i Eg a=10 : a (type (a)) = 10'S ‘ re Ciypecay) r C2 9437 puint (type Co) ; O)P = dais, tints § <= class, 'floatts <= class, ‘Complex'> T =n python we use "None" Io Whe value uel or we dfdn'h asstan any value fo thy voufable > g : é 4 indfeate that we don'h know § “ \n_ python there 9% h te no chav ype you w wank ft a. aga, reuld Eg - Sky_= “gtg" (Shing § fsa sequence of chav), F paint (type (atry) J [.10, 20, 30) (_@tray and dynamfe ally patol (type (19) add and vemove thee. st Irems are stored fa conte. ~nuous locaHon) Storae ~ re eae $= {10 30,30}, “difference fy modi Sek_& a _collecHon of _ Ss pint (type(s). where all thems are _ = t and set UW dike mathematical Set) y “ w Oyu », as J ~ dz fio: "gfg’s 20%" ide" J dicfonaries ore uscd to_do a paint (type (a)). ings. Jhe & a 7 3 J collecHton of key value pairs) > Eq- thems : porices rollnot Name. ai > p> Type conversion in Python - Type conversion > se 3 Implictt ExpltetF a fat !0 €g- 4 "135" os J= 1+ dnt (s) > ‘it (0) f= float (4) 3 d= true patat (3) es atd paint CL) 3 patat (e) : $ X opp = us ojp - 14s » u 135-0 fg- d= " geeks” wT SJ » paint ( Jist (8) > patnt (tuple (4)) Py pafot (sek (43) : p= tigi. tet fet ht Mt] a 1's") Date ..... 9-3 a= 20 patint ( bin (a) te = palnt (hex (ay) aaa + b (oct (a)) a | ¥ OP = Obio100_ | URIVE H 0094 => Comments fn Python ~ ate 1 We may with to deseuvbe the code we develop. We 5 might with~ to take nokes of why a J sechfon of sept p>, a for _fnstance. Formulas , pocedures , and sophistcaled business Jogtes ave v iypfeatly explained wfth comments, # TH 4 Single -Jine_ comment - # a Mult? -Jine comment - Hs. oe ie # te a Doc-stying - the string enclosed fn trfpte quol-es 4 that contes _ tmmedfatel after the dettned fm ane catied Python DoestYing, @ ¢ v E =P ib else and eli? in Python - ig a pans %e Shee come _sthuabous in sea) Jife when we need to do some Specific fask and bated on some Speci pte, é onditfons and, we declde whak should we do next. 7 Similarly, — there Come a. sthuatfon Ph potoqvammeng = whee a ‘pectpfe tak & te be performed if O spectPhe ie conditon _& true. & Seat Lh Me & ~~ Date . in quth_ care, cond?Honal . slatements can be us condivvonal statements ave 2 So ~ ig. elie = Nested if s SF. tp nig. statements. cee s ement ~ tn Ist ¥ R= stat t th ip the condition & true thea pout executes else the elie pout executes . 3 " Syntax - if conditfon + % H Statements to execute ff # condition &_tHue + Flowchaxt — > aS Fi Test False ¥ Tue % x. Body F FI s —S y Statement fust below ) Ce ey + Example - if lo 75+ y puink ("10 & greater than 8") F i paint (“ puogram ended) O[P - 10 U__greatty tan S- v Program ended ia J bt Date on. fe ( if-else statement ~ block of code te when If tend ip: Statement the additonal = slalement -whfch perfame! recutes this “block if condiNon & true ele: 7 # Executes thts block if # conditon & false Flowchant ~ 3S t a zy q Example = a= 3 a : ip we=4: eh! 4 pafok (yes) ‘s ; else: J paint (“No") 4 Fxample- You can also chain ifelse statement with more than” one _conditfon. : ¢ Jettey = "An" i “4 BP dettey 22 "a": pint (" JeHor & 9" a else 3 TE deter = ="c", paint (CY detter ey Seeat Sy ™~ we elses Sp iettes = : Span Craton ba") fi dneiu Sue ‘ ele ; Jette unk: AS and ce” it es cao = 3 Fo? - deter UA Nuled_Y Statement - if statement _can_alte be checked inside FY othen_ if statement. Thu _tondiHonal statement G called a —~J_nested if statement. thuu_means that tnnen if condition will be checked only iP outer it condition %& true and by thu, we ean ste _mullple condone fo be sahisffed > gyntoe - if Ceonattion 1): ~~ i, # Executes when condiHonl W_fuue . ip (condttion 2): ~~ Executes when condition 2. true ~~ # Wf Block t end here ~3- # if Block &_end hee Example = num = 10 it num > § : J putnt ("Biagen than Ss") ae it num 2= 18 5 paint (* Between § and (5") — ole - Bigqet than § + oetween § and iS ite eltf Statement - shortcut of theelse chatn, while using if -elff > statement at the end else block & added which “& _ S_peitormed ip none of the above iL- elf ctatement tb __frue. Y Spnat Date .... . Syntax - i? (conditfon) t = Statement elif (condtHfon) : stalement 4 4 ; = L . = Bs) elses « a statement a Et Example - —Jettey = "A" 3 ip dettem ss em: _paint (“Jeter & 9") elif JeHea == “ct: putok ("“JeHer uc”) elit Jette == SA": paint (" Jeter & A") elses pint (“ Jeter isn't A, 8 orc) OP - Jeter GA > Aulthmetfe opetators - They gHe | uted to peiform mathem-_. =aHea) operations Jtke. additonal, subtrackon, muthip. -Itation, division. ; _& That axe 1 onithmetfe operators tn_. Python - = O Addition _® subtraction “_@ Muiiipixation @_divteton @_Modutes © _Exponentiatton @_Floor _diviston i “ay Date I Onevator -_In__python, + 4 the addilfon operator. It TW y 5 0 tet odd 2 values: si 2 ~~ Example > voll = 2 val2 = 3 SS ess vol dt val 2 SF _puint (tt) —j_ fh + £ Sos SubtracHon Opevalor_- used fo subtract the second value from he fick value. 5 on -_ vod 3 val a2 2 Ss des = vobl- vad ~~ paiat ( He) So as Modulus Operator - sJo u_the mod ulus. opuigtor used to find ~yhe_Yemainder when {fest operand t_divided by the ~~) second 4. Example — vol 1= 3 vol? = 2 J dea = val l Yo val 2 ~S_ __ paint 9) > 0) Pace h +O Exponeatfatfon Operator — _** used to raise the finch _y operand to power of steond. x Example = voll +2 > vab2= 3 > ves = voll ** v2 a. prtat (ts) = oe - 8 Spnrat Date ... + ® Floor diyfifon - // Ss used fo find tne floor of _the ustinh when first optyand te divided by the second. Example - vall = 3 as dis Eps pe a b Nald = 2 ib Uh Mes = val t// val 2 ie bh patot (es) ge bs 7 pee ojp - Pa es __ # i=> Puth logit 0, ith Example ~ 3 ‘ython ogica) Opevators with ample - Operators aye used fo pot opeiaiions on values and vawiables. These ave the silat symbols that 0 and b>O: SS , ne ees piel. (ome oe WE es fparons and b> d 6 70% es ie : SF pata [2 oe mabe ou ane aye _guieator than") elves. ~ tol Tepmeast one number & 4 riot greatut thanso°} are greater than 0 FP = The numbers Aileost_one_ number U_nok geal than o. ~- ~¥ Example > a=to Se eR i cz 0 if a and b and c: i paint (“ALL the numbers have boolean value as True”) Sy 3 — >> else: Ss ~~ puta (“Atkast one number has boolean value _as False O]P - Atleast one number has” :boolean value _as False. =e ~~ Falte Output Tue Output ~ > Example - azto : pS be -10 es eae c20 ™ if a>o or boo z . then of the _numbew i agrestet than 0"). na ben ts ps s th b>o or emo: me: : z _puind ("ef Mhey of the numben gusset than 0") else —-paint_{"No_number lu greaten than 0) DIP = Eifhey of the number _U Greater_than o : No_umber i _greaten than 0 — Example - a=to +. brie 4 =o } iP aorb ore: pufot (“Atleast one number has # Tue") _ boolean value at else: pink (“AN the numbers have boolean . False") Value at S/P- Alleast one number has boolean value as True. | = Logieal Not operator — wouks with a _. R224 ts a id _— ys 20 wt a ie “Yet = [10,20, 30,40, 50) _ = E(x nol fn dist): a ft NOT nt tn ven disk _pulat (. ats passe gf sk”) elses ace i 4 fs + in ven Jfst" int ( xis paesen i gis fs ‘) ety tn Wt): aint (“y fs puesent fa given Afr") -s else: ~~ patnt ( iy is Not puiesent fn given Ate") = °, ©. ° 2, OP - _% fs_NOT paresint In_given_Iist. ~ y fe present fn _afven_Itet SS wt v - \dentity operators - Thy ane used fo compane the object woh’ the obfeds ave actually of the same data type and shove the same memory Jocatfon. a There ote dif wank identity operators such ad Nis operator - Evaluate to True ff the vanfables on efther side of the operator joint to fhe same object and false a} f othutuice. Example - me S 43.5: portnt (oc & 4 fd) fa Sport } OJP = 1407045 86672032 —— isin SENS Ie, both the vay Hore, tn_the S asttgned to th fi “and which? why eure Ty Ss rot’ opwator - Evaluates fo folie ff the vaxfables on _effhen | stde : of the opwiator _pofnh te a ditfount objeck_and te othuwise, 4 Example. ~ KES S2a0p 4 iE (type (oc) fe nob int): | a putnk ("true") . a elses = paint ("fale") = b # Patnts Taue = & Ke Sb iy 3 It (type (x) fs not int): i . “ " = paint (“true”) i else: & t punt ("false") a . '. : > 1 ¢ 7 i ofP- False a Taye) 2 => Python Bihwise Operators: — & Operators are used to perform opeialt e4__ gS ie ea an perfo peatons. on vafu axiables . ese ane the Spectal tymbols that cawiy out _anfthnee and loatea) computaifens. he value ahd operator opevales on is_known as Optrand . i : i wy

You might also like