You are on page 1of 10
Class: IL Chupter=5 Qetting started _sotth python Python: Python is a Generel pupone high devel progtommmning, | language ured for deachoping, appli cotion pofhwores . Features: eHigh tevel free and Open gource Core Bengitive * Interpreted * Pladform Independent Rich hry sDynmic = General purpenes. —, “bF¥" * Easy t Uncleystanel. Simple “Hebto Wedd’ program - print (“Hello Wodtd”) * Output = Hello Word Execution Mods Instant execution of dndiviclunl stalement Convenient for tating sing tine code. Cannot pave pralenunt fuhire Ure for fulure Wet. Saved os “py”: Python Chisedler pet ' Valid Bet of characters recognized Y Python lernguoge . eAlphabets : All capital (AZ) 2 smatt (9-2) ® Dighte: AU 0-4 @ Sye Special Symbol Atl kind hSpectal symbol," "| ; Os © Spaced fab pare, bonk BPH Nee bine ” other * Al ASEH ond Ont WE charackens . Allows uz to vorite ond etude moe tan one Matruction together. Cen pave programs fx [ Tokers}: A Token is the pmattst individual om? in a pythe? Prgam. All pletements andl instructions tn a progerm Of built with tokens, [° [Regeeraa): + predefined words which have spect meoniing to Python Mrierpreber. * These are reserved Words © Case ~Beaisrtive. False | clans | finally | ts Jretum | None | continve for lombda | dry True | def ~ | from fesatocet while [and deh global [not with a | ait [se | or yield | assert | elpe | tmpor pos | break | except Ta raise b Tdentifrers|: Used +o ident ty a Veriable, funcHon or any other entites in @ Program. Kulu (1) Name should begin with an alphabet ov Undengcore ign and can be followed hy any combinedion of charnckrs a-2, A-2,0-9 g (ii) Should not be a reserved word or keyed. (ii) Can pot Use ppcdal ayo Ske 1,@, #, $,' @v) Ext Marks], myVasiable , Vartable-1 P]Wartabien]: an object tat occupies mumoy APA rohich Can contain « value. "con be mumnic , alphann mnie ov cambrnation ob both. Studenk = ant Cinpot (" Enter Roll No”)) b> [Lerate]: Literals tn python tx defined ax the rao dasa Axs\gne to Voriables or Constants, while programe orn y- Osting Utaals! A cay to represnd Jed fn python by encoptng In either Sing quotes or double quotes. They are used ty afore words, Zentenar ™ your programm Single Uine_pting - Ling (1), ("") | String = hello world” — Multiline string - triple quotes ("™ ” oD) or backslash( \y ab end 4, line. Str= “"" Welcome to —, tiple quotes Nitin wm Pabiwwel Str +" Welom\ ]- Backslesh “ Py Hon” DNumeste, Letesels » Valuers thet represtnk numbers. — Immutable ? Thtegear- Both +ve 2-ve induding 0. a None Olist ®Tupe O@oretionory Det, ! Speciel symbole toperforrn Specific operation on voles © ArtthmeHe Operator !. [Operator] Ope cadion Example + Addon 27 Num1 = 5 ~7aum2 =6 277 nem1 + neMe 4t = Subtraction nom2~ nvm 1 * Mausiplicatfon | uma * noma] Sire p74" L [s0 ‘fnelia India? ivi numt = & 7 Diviaton tomas 4 Aum 2} nurs | 0.5 ht | Moduls fuma' Ceemetndsy) 2" 1“ Num2 " Floor Divisfon | num? HM um? (0 %ert) 2 numie 3 r KA | Exponent num 274 (Power) num NUD $l @® Relationat Operator OAssignment Operator Operator | Operation Example ee Equal +o g l Wel pall os i= lot Equi wl ° Tree > Greater | x7Y | than True j tenses ney then False 2 | Grreaberthan) x >= Y 01 equal to] Truc Le Lens than | <= y lor equalte | Fabre Operator | Oencription Example = Aegigo Voln fom ng m4 ~ bids operand to lepf sie i opesand e 4 Fe Addy right & left & amigna | += y a NH % oe Subtradd right Ble & [may Consign real ty: % r 1M 7K = oe luttiply both pidys & dg * oaigir remuld do Aft PU Jz Divids both gids B ae 8 ~ \ ul fo tele. | Rye Weiga 0A a Aes 5 3: “Powidts BON yn resus WyHEe= gy 1o exe Baponeoted & resath aonign tap] 0% Y an zis 3 Hioor dwinion 2y r g | @ Logical Operator Operator | Operation Example and logical AND | A= 2° iF a<30 and a7I0: print ("Yer") or Logteat og — | A= 29 if @>10 ofr A275? pid Yes") Not Logical Not ds-sonny = Tee bs rainings Hot ip-SuAN: \ wining i. 1 Operator Descsipton Example ts fetums Tras hea Operand '» tyre & reve) bs tnt datatype “re same | Truss Bb not — | returns Trae Wheo, | KE 12 operanclip detaty Pe ype) ds int a clote. hy Pe cvs Rot | False ’ on 7 © Membership Operator Operator Oescsipron Examyle 9, Rebar tru if l= [12,2 10 (2,233.4) Found iz WL Tru Ao in Redurres True VF 23 tab Not Found False Type Data Type Pepuipton Example Tat “Enteger numbeng 210, +4012 Number [Pleat Floating powt Nem — [-3.09, 7.0234 L Complex Gorn plex. numberp 344i Boolean Boot Boolean Aumee ot Shing Set of characters thewe’ Sequence Upt Set of items Separated by » GA [12,3] Tape Sek of itera Seperated by -| (12,3) Missmg Value | None Signify abpence cf Veuus | None 4 Mapping OtcHonery key venkue Pedra (ori bio} [Exprenions]: combination of diffrwnt valiiables, 0 pereko, and corutantp which always evaluated ty avelur. 29+ Ia 4 13 (2340) +18 askeed a5 +e whe? 53 step > ShiGwas|: A shalement ts codke unit of wade thak the pythen Tiberprder can excee- = Var = Vere thowsignment stalement «fae fnpet (eaker’) Ht np stalement. * Converting one type of data to ano whet type Bupliclt Convension= obse repened 40. os type Costa am tp, decta +ype conversion W forced by progyor ran Syntax : (new- data-type)= (exprewion) intlvalue) convert valur to an Mbeges |_float(value) | Convert veluee to._point number Str (value) convey valur to pling reprounta. chr (vole) convertp value +0 0 Characker Beichr(value) — | Convent, valus to a Unicede Chae float to it = 1Q =2 pant (ey) H Oudput> 9.5 pring (eqint (A/y)) Ht Oudp= q String do int me input (" Enter”) ; pink (x42) # Oudpuk= can snily concatenate ste do or a= int Linpukl" Enter”) ) pant (42) an oulp us* dipplay addition efx % 2- String +0 feat m= 10.2" yeti a fenty piv) Dutput= t0-212-3 iz Float (4) PFleatly) print (x), tt Owlput? 22.5 L, Tmplicit ConverSi01? + atows Conversion from pmeatlet dota type + woider zize clata type potthouk any Lop of informad of. — aka coercion. — done antomads oly, Exomple.- int 40 Flot Var] = |0 Vor2= 3-4 res = Varl-Var2 print (res) print (type(re)) Procems of fdenkifying and removing ermtp. Mipdakis Lohile voriting program. GU 4 Syntax Enor + coriting wde vagasnat programming. rules of python Such as using wrvng function game, porns frdentaHon. .. — prgremn can nok be theented untl ik ds Ay ntach cally toect . Exomple:- > (F410 Right bracket —> X= inpt ("Enter) Hoang fn name SIF xy! pind (x) af Wrong Indentatton 2) Le Z Piaftel cren: Gsoneet exciton ob progeam, TNot producing sight output. Example if x =='0" or "Cori pO or u's print ("Youel”) “ pant ("Consoraas”) Coreg (iF Ha='a oy nae Cor x=e'Por x=='0° or xe='ys print ("Vowel") dae: phat C' Consonant”) i to" program BRunkime error, causes abrupt termination eh prog hurt ag eheendon: —appearp during creuction only, kample:- fvipion by Zero a " . ‘rat Cinpwel "EnK Oividend » ys ind Cinpud (Enter piviser”)) print (>¢/y) abruphly,

You might also like