0% found this document useful (0 votes)
26 views

Python Assignment

python note book matter

Uploaded by

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

Python Assignment

python note book matter

Uploaded by

Pavan Borra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 19
by] wisitte alsout operators 8° python % NF Operators aye! Used to’ parkerin operations on orem ds such as vworables and values: “ie | fallouting Ore PRerent types. of Operators ‘in yon, ; fithnnatic. Operator . : © Relational oferater (1) comparison operator 3 Assiqnrrent opercitor a hopjicol oferator S: Bitise Oferattor + 5) Membership ofercitor , > oh. Ddertt Operator . i ; SArtthrnatic, Operator These ofercrtors are Used to Pertorrn ovithmnatic operations such 0S’ Addition, | Suipbrackion, Muttipliaadron, dvision etc with numeric Values 1 yt gh yee het GQ=lo, bed Operator Meaning eG" as | Slesalt | | + Addition ote ty | | - subtraction ©, edb os! | - | KO Multiplication |. oto ee / Division alb , Oe *, Modulus ofector acho 0 to yernoindey eK | atponent | CukKb | 1b0 LLU. ongiigontings) attb | 5 T+ cperstor ia applicalele for sig ‘yee Fe ie concatenation >yOTOY - { Print (! eq + ‘coltepe!) | | Olp- 9 ore ‘ol lec we | yt? one eee athe. “operand is not Q. «sting Ype | then COS, lag Exror Péint Cal - + (0) Tyfeenor:: can only Concotenate str(not ‘int!)to | Set can also be Opplicatsle for Stings | Repetition operator. IP 0. ‘oferatoy 1@ a ony % Ee strin Np pe, OMe ar amen Shoct| oped iy and ober ty Shou \d be ‘int | Eg Pr pfnk C' Hello! *3) | tello Hello Hello * sprint (2% Hello’) tello Hello ttello Pech aot) “TYfeerror- cannat _ multiply +the Segjuenes bg no ~int ‘of peste 2 Relational opercitors o Connpavison pest tars 2 */ Compogison, - CResators ore. “Used “fs Gmpore {00 values: 2 Opercitéxs yesutts WA either True y) False het O=l04 b=80 operator eas Exosnples Result z hess thon aso . Tue | 2 ve Creates, then - azb False | <= hessthan@nejud. C£6 9 True | Ze Grrectis tone) azh | "Calse | E9juUal +0 \ | l= Not €qyalto Al=b: “Tee == equalte = Ges False | Sy/Even we Can apply Relational operaters Sor ran fe: TR we col Relational operdtos — Por “string type, the! com posisan usill boppen based at. Unicode [AIT Value oF sting | ay pint Cale’) | Slpr False te | “k Note ae oo AY orl) Punction con be usecl-to find unicod Value, ob a character Sy Pinto cx") ! {co \ ' 1 Pink CoC) en | _(Dehore.a Punefion con ibe, used to-find chonet “O Pre Aven Urficode BQ. Pint Cohow (Q4)) a - Print Cchor(Q¢) ’ b= False i, Bint Geb) —> False Print_@ac=b)-> false. _ Pilot Coxb) > true Print (0>2b)—> True: iy? OMnot- apply stelotienal operat for incompatcalsle - (cow occur: types, otnennutise “yfe Sxror EQ" pant Co! a= Tue | | Gnnect A value chtavned. b Expression Fokse ORe. True etl tS mercies or! operator results True [Prevator ee | Expression | : FeBo | y-otb its T+ 10 ri=mH10 Te) Melo | mem-lO es M*=lo | m=em*io. | l= , Mlslo memo | = Mefelo. Mem?/. 10 eal NYE = M=MAK O° 1 Il - | (1) m*> [= moll =l0 r= mllio ENaluartin hol iQ come hirer OPercitor {50 tS a Aas \ iP atleast one of h. loFical Operators = Lomical OPercters are uselte More relational ofertors to form a | Complex expression Callecl hogical Expression iN9 Q hokcal 4S aleoays hogicat Gither “TueGr) and! oVerotor results True if both ofeiands | | $$$ Operator Meoring | 4 eee ; one hogical end | GéalandG73) False oT ‘ hoqueal of | (64a) or(S23)| True tee |_heaical vot | Nob C549)! True | © Tents operatons + 7 7 adentty operators are used to COrnPave the! | memo hocation OF 000 Objects. 7 There ate! tu06 identity ofeators “in Python | =KiS : ae sk isnot ) Im 1 T@ My returns Te iP. andl only if _ both seferences are Pointing to Some Odyect] | Address and. False otherwise =r TR oy IS. NOE Sy ‘steluINS “FUE 3 andl oniy ie both xeferences “ore. pot Pointing 4p the Same address arol False others . | && [aslo ihe 4 = b=lo Print (ais b) “True. ‘Print (a ‘is not b) falee 7 Q-O= bo _ a b-a Print (a is b) False Print Corts notb) [rue 243: % L193) Ye, Qs Print (x Ps y a False - ) AOEEISHIP operator. The membership operates aa +B check Cohether the Given Object M A seyUence such as ~stirg, list,) tuples and dictionaries U ‘ sylheve ove 00 membership oferators | sein ‘ ; } 4 sg NOE TN : i int This opedior is used te Pind on eleme =n ‘in the specified seoyuence . “Te rettians rue 72 elernent 1g found Nthe specified Sequence else it yetums | pet False a fia,3) | a * b=3 5) | ant Clo in | Pte | —_—_------——_. Q S='hello! print Ch ins) Wwue | DOIN THis operator works In mEve”"Se mon nen for Sn’ operater 'yTt returns true % the element is not ‘Round “in the Specifiedt sequence anc 7? elem amt 38 found, -then it returns Palse- E4> gchello! Print Cat! not ing) “True 3. print CAS hot ins) | Fo + Bitwise oferators:- Bitwise OPetatots Are Ug ito fexfown erations at binat, digit: Jerel. |Wese Spin ase net comminty Used ond jase Used only in Sfedal anoeVi ie: eee 2) See Spl The below are +he jy isaac tWISe oO lavoila ble an Python. rears { | [| [operetor a a 1 | | “Biwise “qin D | \ Rrtwise OR i A Bitwise fuclusive oR! SD Bitwise TNnvernston AoPkchiftoperater fc | or i peste operator Brkwise Operator can be used Ror tnt Pe And koolean type Otteruise Unsupported OPerand PRS Err Type error Occurs: | Bitwige and segutts A lisa £9 Pint C415) \ a Print Ctrue | False) | “True 1 both | 3 Biislise we Xeg t- Tis oPerator yesults " i "| bits an are cifPerent and results iat a | ie Are Same. | &- ae C4 AS) brick CTrue A True) False pring (True A False) True ke. Bitwige complemen’: operator :- This Operator TQ Used ts pie “the bits Bam oto 4 ard Ato 'o eg ciate Cau) seit opester:- “These oPerodors Ore used anette biz of the Nabe te she i‘ the (eft) “ante by the no-of bits Specified yesuttS 5 4E | T ae ates one bit [Sy There Ore 00 tues of hiv openater I i ereftchite opera’ eae i 6. Right Shift operator (37) . 5: hePechift Speier c- Ths operator TQ Used te Shite the. bits hte number to the kee by | the nook bite Specified) | S9 jocca shite g, bits to the heft | paint Cio <rQ shifts a bits to the “ight Print Cloz>Q) 7 The Following table lists all the ofeates Peony highest Precedence to the howest- eee cree eee ere ay Oferalor [ en ae | +t a m+— ofc wary puson # Ul util divide, Module any Ploor “clivésion | aa ¢idakion ond Subacton | | alee ight afd Actiship. Diteoigg | OPeratars \ Fe Gitutse JNO ee Bwise relugve OR and eee Comparison operators as Sal Operators =belelle = | aest Amenk OF code (Sat poke q fe 45. ‘Snot Teeny Reales Noe ot Gnd | logical Operators afore - iin “gfe Baten Pancton i Wowin A) pincons 4 are eae type buile-in dy care aly) atv) cit) reprC) CY typeC) Gempc)> ethts function can be used to compere Kod ‘integers and relum -1,0,1 accorcli Yocmp Sy This Vinton vas built-in Bunction -Sen. Python Por Comrfarieg the values of 400 Objects, =yit oesrot, orl i Pythons and sped Coit the == and" iS operdtors ai ~ emP (ail); a,b afe +00 oes yeturng -| iP adh © if a=b . \iRarzb Sty 0 -_ Sane Comp Ca, b)) oles -\ re rrrcneed pant ccmp (Q jb) Olp- | (hanes Sn Panction can be al jer type values to sting : 7 Symtoxs strColgect) » Here the object an be any data Pe ~ P72 Sr Cio) Op Nig! PD Str (10:5) | ipso PD Str Lto+ qj) LP Notaqy! 72st We) Ole: Tue! Psy CoBin)-> First 4 \ Value OSI] be conestel into decimal Sim. Then run -en 16 represented “in string Porre) ole V5 | } ‘ al) Yepr) }i- The yeprc) Punction can be used ts Yetuurq Sing Corton imable rvePresentation’ of. cn Tagject 0 i p ; “ySyptou'- replok) OW}\-F The object cohose Printable re -ntakion 1 to be returned Yeturnti pes Strin ey Pring Crepy(to) ) olp 10" (9) Pr print CreprCios)) Olp'- Nos! | @) Pant (repr CTrue)) Ole ' Fue! | 8d § cae CrePr (Ja) | ole | Giga Me tyfed 49 Used to get the ‘type an object: when a gine wment IS Possedtto 44 Fe) ie teturns the “fd oF “the olyect- Sy Tes Valve 1 the Same a5, the object sree Clogs. ++ instance yarialele. y MOL type Cx) Ne Print C clo) ae hs () Pant CtyPeCio's)) 5) clogs Ploat > a i is ee — Oo , explain wel Susting fin Python? W] wlebsurfing:- wel surfing falls under client-server archite -cture umbtolla that ia as follouws:- Sy client- Sewer architecture tg a. distributed) computing tnode\ in a client machine makes oa. quest “fo & Server machine, ard’ server | machine Provides “he client with the tequeste -c\ S4xvice (@r) YeSource. , > Th Ais Grebftecture, “the cliett rnachine Usual “‘nttiates he Cornmurfication by ending weQyuest to the Server machine then Process the. Yeoyuest And Sends the sesponse back tothe! Client machine. The client and ervey machines, Con be Connected ovr a local d\rea Netinork | /|CAAN) | Wide Grea Netoork Coo An) | Grea leducsta wee Webs | =yThe webclient Ta a browser @) apptastor are responsible for “‘intero.cting the request and displaying the. response. tb +he user, Cotiile the Sever “tg* responsible for Processing the | request and providing the Tesponse 1 ey Serb) 4 iio iieneengremnttl Po for client Neoyuest process “then ard NN vetUr phe uestect dota: > Te eben and webserverS re 2b commurkcation using standard Proto@! Coll) OS Hypertext -branefer A eccnl cute 7 We susifrny worth hon Picall Awol ve wail hon “ Gbrovies . Und aired to peste ike Sendin TTP requests, Parsing ae and ‘interacting the eb poges- oles Ore Some” Eromnples What We cn | Q02.- DSEESIY ATIP teqquest:- PF We CN Use the Yecwuest module to Send TTP requests and veceive vespong From Unelp serves, =7 for 29, we can gd a GET veryvest 5 ~ Welnsite ard retfee 14S HIML Content “7 Trnfore requests , Orle!httPss |] Couto: eAOrTPle-Com Fesponse= request get Curl) Print C Yegfonse. Content) BQ) Parsing $M Li- : Whe Ann = =ywe d% Use Parse library lke SBeoudita Seo.P! to forse eel cee and extiadt [Speci iafaenation Plone them. eet ler eq, WE CAN Extract all -the tinka -Prom a tneb Poerge from ‘bs4 WenPport Beoutefulseep import yequests Or} at https: /1 Wtol0- erample. dom | TesPonse = Tequest getCur}) Soup= Beautiful Soup CreStonse content ; herd. Vioks= Soup. Pind Avi cra'y P™e Por link in inks? Print Clink: geec href") )

You might also like