You are on page 1of 9
Pes ; Verfables: Tease Sensitive Jo python we hawe- buillin fanctans 1wede- yes ond doko Chamber = 4 rap yexiables Can Chauge abang tome #You don't need te define dake bype. enython % dynamicaty typed | poaigrment pera. (&) | —tWe use typer> bb knovo the | data type oF @ voufabi * type (number) > zclaoe int> —zmust stak oil a letber,spaces aye not allowed: wo numd > as) instead pot Grams) nama 26 print Guin a) coum: num it awn 2 on 1 Merckens 800 aK -tGives poo vend fst randink @,b) —equed a random numker plo ab tmpott random health=5 0 polion-health «random. randint (5,50) health - health + poton_health print Chealth) Tapecasling : fetcing a data type nts another data type Yound -trounds tta numbers b tte nearey- tnkege Hodt ~eyounds ts tte lead gm cetl ~¢ vounds 6 aveakest iol— “ malh mod ub— jet"! An pytbon stain Cc) Broken stings T are reprencnted weg message . “ohn dard “We 15 fine" Here He 1s fine iS broken dbe becauw TE 5 in bho enottar, tus ot fie ta Se catty single quoles (~ 1) messege = ‘4ohn said “He 16 fine fot lara beck. we use biple quotes three seb of double quota > v7 ot eC”) bakeng fopul Se Fopuk (Mulkad!4 ws nan’? pant) fe What ur nam?! vfatyaed Utdlage. Shiig Concatenation A2* partone’ B > “part boo” A+B - 2otmes lle cannot concantenal latina and a “number”. direckly A “park” Bea Arétr(B) pert + % 13-1}, format &B) past - 4 14-41" formal (6) » vet! mame. fopuk Cuthat t2 ar name") joge -fopa EC How old axe # =") [aity -topuk Cutbak city do you liven, love = toput Cuihak do yoo lowe dog Pang Your name ist { Jend erordy gow toe“ 44 aud you low doug, Outpul- fem ste {oemat Fame aye ee) pan (atest ee ‘Shing | mettod> = string . method ) | /CeankC ) 7 “hetlo® count Ce") 4 ext “happy” teck-count (Pps . 2 | beck count * hape peony) | lower) oppers x > “wappy")) x “happy? | X-lowerc > x ( + wppere borey upper) Haepy fmm bu RX *Xlowerc bavey Capttalizes ) x. capitalizes) -e capttalixe the first le Hapey to HEC) —e capitalize ta first letter oy cueny cootd Xe “tapey Verte 7 x. thle > Happy BYatkd Pe “| Spee cope chanel folowe FC) —~Z tells lowaca ot ate” SSupperc> —t tells uppecax een! (Salphacy —e tells all the teHers are * alphabels cx nol fodigtte) —atetts all ase egie eaonts falnum —etelle all axe digits cealphabele frder—e qe Wee BB lant tudew Ga pple Seder touts ult. 0°) find alo aed fudee *AU am meltkods ae Cac sensi- | lewe Hip clei gt vemowes a particu- lar ablelter fndexe ) finde ) Giwer ere colen | Gives “-4% Jan wnanyromou> | coithout Cranf Shing (9 there “s ec x. finder Cabedjke2y 10 enct xfind Coabedbkinepqr) = | dltefn 19> doubh aon immutable - unchangable Aberable -kle can move step (| by step unt coe move 5 te end rs ob fngp are extberable_ datatype te finder Stars coil “oO” Pion ew | Wetd 2 “super” Wecd{o} Ss aan 2 Variable [ota end step] cootd , * ouper posse) ss woetd fos 5: 1) super cot “Superpower” extd fo;.5:2)) Spr Gockd »* super catrfragilestc % toot (58) stab wilt “05 & calihragnstsc fe coord [274) t steals itt “0% ups 5 Supercate coc d (13-1) —t veuerse a tie leuk cot (1) ices te taal leer c coots (3) tk coded Inder (Catv) a” coord. tndee Caper) —e ius the Fadew 2 fp fina letter contd fine d.inder(oat." : cootd.iuder ; Crag) ues ple frag Cali doy ee EA Boolean & Compare” Operates > C pte, )) ue gees Fos f stafemenlé ontae — tf condtkon: Stakimenls feb ayn if condskcon : » okalimen bs elec: Stalimenl™ ato bat ff arb: park Cat grea than b) bes paink(“b $9 qeeale: tana") iLelifelse 2 if conde: F cond oretelBmenk Stonbs elifcond = el cond a 4, Steonls otronl mi elif cond 3: olmols a A210 oe tend bets é iF arb: pant @>b’) lel brat pra Ceo £) elbe pmnt Chott ae equal’) Spee tS logfoal cperatst» - Gotan dyot) —Combtnes tt Conditions and = All condikons must Galisfy Ore ea Conditkon rust sabioFy C210 oO iF C>10 and day Print CE cootked ") 0: m0 op C210 be if c28 and D4Io paint Cie coot hed”) Dp: t worked ClO OS if not (DCD pain Cit wetked ” Opt tk cootked c+10 DS iF Dpn ot e710 print tt cootked” ) ; Rithon Dela cShuckares Owes ae therable elislt Lr“) or aa Pytion Wo can have mulkeple data types in sb jackson (“Al “eh U3 3 True Fala) Aackson (3) @a {aw bal [otast- end: step) “jackso» 0125) (wees! @urltot - (1, alan, she 43) our-list{2} na wrote (4,5) our- Mot (2)(9) 6 Viob_fnode ol oubetable- [fia,3}, (56), bs] Our table (o} te) Our table (1) [ne] our table (0)(1) aA owr-table (1}[>) 6 494 a Inteyoerd Le (15,2634) 2m Fue eto mame +: input fenta meme 1! TF mame in known.user print ( user t vated’) we Prink Hello { 4” foemak Gam) 2h: . Eater name ; gree Hello abe “vemoue keyoostd known-users + [“abe’, “ede " ) known-users, remoue(ave) del Yemove Mt delet known_users. nprenl Gatdeye’) tremurere (abe) Sede} “sqh') AE deletes tte fir wing jader Appearing element even & ae mG) 2 Al est (123) ; Giues au er) a -oalyas) : print (a) j (% 12,2289) 47, 3 A At bok (ob Gad)) 4 yy (s, 121 SWAG % s) A- ai([s6. 7) A ban scone bserd) ‘Aaggend (to eiurd) la | 9 mssinrKeoriplons)) pl ee AinsesE (108) (a oo.arss23(5648) lets) > | faples ave immutable -Onelang ett hile WIT are rulable tuple - Gayn ‘Bl eal) our-tuple (0:3) 6D GMA 2 "y8q¥ eee Tuples and [fo are deme Bat tuple f> unchangable cohile [fol axe be (rmubable ekonary ef} ey and wales Studenls | “alice 1a, ‘Bob’: 26, “claire? : a4 stadenls f Bob’) 2) Shudenks (“Fred } 22 Students (“Fred *) rls del, del Staclenls (fred) Pedeetx fred okudenk. keyre > (atce’, (Bor), ¢ 2) (2) [ay 2629) t Studeni> { “Alcce’! [10001 26, va'}) “Bob": (“10008 / 216’), Claire’ -(*10009 4 It, “c') “ctatre |) 0) Project film = "Fieding Oo": (35), “Bourne? :fig,5) “Tarzan (15,5), “Ghost Busters” ted} cohile True: choice - frpulCuthar filro eoould ~ uke be wakch 2:)).otape >.bibley tt chotce in films? age = fot(inpuk Cte old are you?) ey hl eheee\o) aa Pink CEpiog tie Falen®) else printYou are tso pong Boee teat fil) fF | else: pHOE Ce don't haue Hel film’) Te sepeals a loop over and ouer jogorn @hen dome Condtkon ts tue cahile condition: Code “nan 21 cohile namsz=10: prink Guin mum=nam +} ey From random fmpétk chofce. queskons - ("aly jo te seq v Wiahere to Ke Toon, cohere ave the dinosaur?” queokon « choice (querkon) answer + fnputGuerkon) strip ©, lowert ) While answer |= "just because”! ( Gnower - inpulCaoby?: she) print Cok ok) * fot loops : foe i tm vange (Ym): punk?) rye ee print " ex \owels: 0 consonank 0 fot letter if leller, lowercy in “aeiou”: tn “Hello”: \owel - Vocoels +1 elif telke 22> pass © else! Consonant = consonants, H prin Cthere are 4 eee & ae { } consonants fat Consonant) G wands) OF Tetum % nob students = { “male ™:["tom ) “charlie “Harry”, Frank") : | “female”; (arab) “Huds % Sanan, 5 fot key io otudenk key: foc name in Studenlsfcey}. if @“ in name print (name) \ | list Comprehensions | Jet Gomptchene en | even-numbas [x for y in rang? (loo) tk xi.22,0) prch(uen. numbers ) b, 46,510 < ah def fan-name (parameters) too) nekon® ne a def add Gy); eer) We need te call fem fF we wastitim ai bm GP) SS elt ae ed coe need Paka crefim @tatemen!— edo Yeh chem ah pra = Precos of reereblcode @ -lOReGlobat | def f,O* bo def ficy: print (a) +100 —t local prink@) deere det f def fac >* lef 42¢ ): paink() nt@> 5 ite OP: 4x’ ob: 2) 10 100 ewer a-a90 -~——t Gotal def 410" bal cea A100 ——t local variable prink@ ) deF facy: a =50 P Fm 5 f Cocal vartabb— 40) o> pink) oe: too 50 350 aza5o _ | ‘ | | Thee a 7 aan As | ch Pe “ifeoten | vrekurry Ut add 2 fo tm | fostiansvquanents couch we Cos ar jadd(x-S, OD J kepos ope once each expert we ee oso weed Jofuch makeher add x22) —e These dboald be tavh— ) hefoult> wae [enone Objects and clases Every objeck ft an fnakance of clays Vata bie def fic) +, r Ps pea a ng @ gab | a+t00 ole prink(a) aa ' 100 5O

You might also like