Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Python Assignment 2

The document provides an overview of Python programming concepts, including basic arithmetic operations, comparison operators, identity operators, membership operators, assignment operators, and control flow statements like if-else and loops. It includes examples to illustrate how these concepts are applied in code. The content is intended for educational use, focusing on fundamental programming skills in Python.

Uploaded by

labadeshravani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
3 views

Python Assignment 2

The document provides an overview of Python programming concepts, including basic arithmetic operations, comparison operators, identity operators, membership operators, assignment operators, and control flow statements like if-else and loops. It includes examples to illustrate how these concepts are applied in code. The content is intended for educational use, focusing on fundamental programming skills in Python.

Uploaded by

labadeshravani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 12
Assignment No.2. Nome 2- oStwal Tsha halit - Subject _a- Python CG) Borcithmebic, Oneratar $= +Addition s~ Adds val ‘ Bi =Subbsookian ¢ a ublro.ch-origpt hand opecand tearm eft Kong tlt pol Sp) \ on eh * he ooerabog - 6 [Division s- Owides lelh hand operand. by sight -hang_operan 7 E mf \e O=94 ® h= 10 C= 6 R= O4+h Prsok(" Addon igi" p\_ C2 g=-h L Pein ('Subbsackon ian" c) Cape h. paink (Holkialication ig 5 se) C= o/h au FOR EDUCATIONAL USE ‘ea Ie | L = I. <3- ae “the ® Qoonpareigo.n—O pees. $a |e == 2- Al the values of bw operand ore equol e pst St values 7 dren condition becomes rye o> g- AL the value of lek operand *t garaker. | of oi 1 0 ; -volue of left operand to fons thon the valve ob eight operand the sl Xe vample a= Q=o! b-lg. C=o0- 'aflgeeb\: e Deeiok (" kine d-@ j equal ta by else s Print Chine 4 - is Aol 2qaral bo") “£ ( ols by: FOR EDUCATIONAL USE a @ Bikwiee Opsrabort- ° Bia Ano 2 Opsrolorc opies —o Wik bo the sexu ibs ex in both operands - - + Binary OR Ak copes o bik if it ¢ ie ‘io either oeroad- le Broory Yor 2 44 copies the bk ib set in one. operand but mak both. y le comp)e 3 A= 60 b = 19 C=0 czakh. peiok (Moe 1 =value ob¢ is", 2) cz Oal\h pecink( * bine 9- value af ¢ is", 0) Cza*b > pxint(" bine S-volue of cig", co) Tdentity Operator i a 16_—3= Evaluate to bruce if the vamighle on 2ither Point bo the Sacne object and Calne Otneusige » 7 1G nob 3- Evaluate: ‘on Foloe St the vorrable On_either Side of th : Some alfjeck Gad trove obhermiae » FOR EDUCATIONAL USE. [Eon ple s =C" apple" ponana’| r a = Lappe” hanna 9 sok (y ia 2) pxiak Cx is ¥) $aink (x==¥) Pact Cx is aot2) paint (x is_noty) prot Cx \=v) An oulhon fd entihy Operakore are Used bo S rd : Compoxre ‘he meteor loco rons & two alte ‘ eh ome _ol feck Thi operctor evaluates bo teye “if tho bua Noelle. Point ta tne Sanne. obieck in tena} FOR EDUCATIONAL USE fn deboil Piseahen hie Operstana i [ym 9. penee, Such GS String , lists ox nals —O3[ | Explain_membsxship § msignment Opermbace There. Ore +u0 membership opertors on 6 platned below' jo_8> Exaluatea to true f3+ Linda o variable to A | Se i O: is notin = Evaluates to tove if tt does nok finda ovaxiable ‘inthe Spevified seauence and t Y Folae othetuwise - ° xonaple 2= Q=10 b= 20 Vick= [1 994s] . ! tt Co io Vist): | point (“ao isovakloble ta the list") eloe + Qeriak (Yo ‘snob orvatlable in the lak") LSE (Cb is mob io List) : paint ("b is nok in list) else + print (bis in the list) FOR EDUCATIONAL USE | = | Basignmenl opstntoxt= > +0 sign meat operator in python Gxe_ Us ed 40 OA8ign yalue tp vorioble = | Accigna the value on the. right to variable on the [Neth te: dt adds the volue and assigns to leH Side ‘ operand, == 3: 4b d_assi l operand, 7 wet 4b roultiplies the valve and asaigna to left side operand fs t= 4k divide the yalue and assigns +o Lefh cicb operand . oe E ample a e aso) i bs to cz 0. : p—C= Ob l Parink (" ath ist", @): C= o-h pernb("o-sh ist" p) C=o*) pat ORES = = Oh, 7 FOR EDUCATIONAL USE On 9 stake differer > aaeReEe —Cantyol Flow is Python afer “to the order in ich In di ins ‘ 4 be Conditional statements 4, hon 23> PS posed on certain Conditions » 4 if shaberment ne ae ia a most i - ecisian erie praia | dt ie used to decide phether oe Statement o@ block ls Condition 2 | #shohement +o execuke-if condition ia true « FOR EDUCATIONAL USE. -— IE oraple 2 _ {= 10 sf Ci>s): peciok (“ii gortoter thon 5") p sot (CA am Oot in if block "') ih- else Skatement- S jt will execute ahlock af Slobement and ff the condi Mon ia Colge it coat » der I Syntoy g- o stl condition) + # Fxecubes if condition is tive. else 3 H Executes if candition is faloe . § Example 2= é i= 20 if Gicis\: Dein (“4 ig Smallen than 15") print (“This ie if block") —__lelse Paik ("tis gotaler than 15") print ("tis ic else block) pink ( A om not in f and else block) | FOR EDUCATIONAL USE | Mis) A [ nested) -if ahabement - | @ necked if Shotement that is torgot af another if fnsidle another if statement Syobox 3 = if Coonditian A) : + Execo} when Conditiand js +sve if C condition 2) : + Ex ww onditi 4# if block endo here . # if-black endo here Exarnple 3= a=15 b= 20 G=6o “f Cosh): lascd: p tot Co i. gatater >) elses pack Oe la guaka) else tl bec) paint (“his greater") elge s psciet lene gaeaker vy FOR EDUCATIONAL USE Le t-elif else tobeneat Here 0 user Can decide Gmang multiple The ik Skatements axe execubecl fram the top daurn | Syobee = nf Ceondition) + oben eat - elif (condition) 3 e Shader enh elge + Shabement - E om ple 2 Qurahex = 0 of ( oumber > 0): © Paint (" Positive number") elif (ovsnber. co) Darin L’veqobive Qumber") eae: pink ("Zero") paink (Ths z r This _gabement j alway exeeuted:”) FOR EDUCATIONAL USE Synkox 2= by lon Glotemerits (3) Exarnple $= S=1 while (i< = 10) pink ("The count io 2", +) fsi+) Deint(" out of while Loop an) \ Fore 2 np othe fon Shabement ig used +o ron_a block — sh code ox Qcerkain number af times dt Je usecl do Sherake. over On quence Such Gd list, tuple Shing che - ——* | Suntor 3 = ——||__for therabiag OL 1A Sequence t katemenk:(3) FOR EDUCATIONAL USE Exasaple #= Tiana 4 erro 0 — Languages aT pythan” "PHP Hap’ “Etr" “nar Lo in_hanguagerd* | gu0g perink Cx x) break. _] Conkinve Poss The hmeaks Staten s Continue Statements |+ Pass labement Leot exita the Skins the cumeat | acta oso Loop completely | gherati ons. Plocehold ex 4X ‘is _use bo Le hy use to bypasd + his used fox See hop Yh | Specific iterobigas |fnramplete code loop coxhy On Alacehal Jer bevak Stabement | + Continvte Statements An pass 3: otemaedt terminakes, entine | o occeds to next dnere ig no ‘oop Sherabon effeck an Loop Example °E xan ple : * Example i f {fox cal “io foe val in Shxing* |for val ‘ia “Sbeing | if ya's"; “hvol es 4" if vale="n': becca: Continue Poss paiat( val) print (val) Pecint (“the end") petink (the End") £. ot (val gxink (“Tae End) FOR EDUCATIONAL USE

You might also like