You are on page 1of 34
[Student io | Student Name | iment Title: Working with data types in Python. Experimet : ive: To Working with datatypes in Python lke number, string, st, tuple and Dictionary, Aim/Objective: : il explain about the different data types in python their programming, Basics of python and PyCharm code editor. Basic knowledge about datatypes in python Program to Calculate an Average in Python Program to accept an integer value from a user in Python and to convert an input string value into an integer using an int () function. Q) frmpeat = rempy Oo Hp anos opantoy( C173) 5 G75 6) Wwe 2 sum (ay [Lene Print = Cony) but pur 30 Ga? bv) nume to pent (Hype Lrusny) tennent ed = Terr (num > pio © type @numed 9) Psiny ( temuesred £20) Bek i eee Z tom fatale 30” poe _| PYTHON FULL STACK DEVELOPMENT WiTH BJANGO ‘ACADEMIC Y Course Code(s) T22SDcl01A_ a 4 ae eee teen Program to add two complex, float, and intey . program to convert integer to float eer numbers «) Program to perform addition of rng and integer sing plicit conversion Procedure/Program: a) nye tronlent Perc) ny = Compler( fnpuie) > Penta PM) fe ftoar(Mmpur ©) i. ftoak ( fput t7) Print (Su) fit fs fot | 2 fmt (Trpurt » fae 2 mE fnput Oy) pint (ity tints) b) as twt( fppurt) grit Cftoart a ) 3, tnt ¢ Enput cy) Nee Snpurey Print( Stecty) hy 7 SF no? Af Jan OF 7302 4f>o7*) 2 25 i Lonm pion — NumTigtrs * seaf processes “ott 7 © tnt2o$ sum = ID' b) 2e2 6) $-§ se? %S lp: A pnuesrech te floot = 2.p9e: 4 : ated Tra ay OENT= | daa eens, 708 ) viva-voce Question® (In-Lab): 1 What is datatyPe? pre urcd tO depine WWE type © rae mora types ype ef vanioble Bo’, fat oat > de ster cnteaes dectenol vod e/ type in python? 2, What is mapping wo fl anoepe 9 type fh a anton ty pe tomprlt2d FA foltectio Cy Keys ond asspuiared solu Af. 3, What is type()in python? } type t? meus the tH7e OF BOA » ‘A. What is sequence type in python? ce) anh eft ent Im am ergon” volutes Sequemy es fa_ ¥. + murtiple foynton these Ort yon, War LuplAs , byreactorys, Pafrer! seu en) aw 5, What is type( ) in python? python —typery 95% bul? prfunctfon Pe ard “12 metom the type fF Aot™ Pee ee Verfaria in the togram- Student ip oleae Student Name print the sum of the current number and the previous number program to accept employee information from a user, lary, and company name fr ask employee name, sa rom the us dy the user to the variables. °F Nex, we wlassign the input ), we will use the print() function to display those variables on the screen, © Procedure/Program: @) numbers 7 CU 9) YF ie ft romae( | ten (awmbers)y) « Ds wrt © mumberc iD preys aumbers fees] Sum 2 Cur ¥ + prey print (durr, Pret) tum) bY id fot Ltmputty) ‘aame 7 in pur UD Solary 7 -fooat [ Prpurt 9% Th « Tat Pn pul) pafar( td) Pint Cname ) paint Salary ) Pinte 1h) ») SESE D Sstvosul? Te ppp ed Gp 01 9 36\ Employee pearly Bote D cfvaint ThOOD DD ou 189 36 | ‘Student 1D | student Name ation of Operators Concept In python F rte implement sun implementation of Operators Concept in python ax relational and ro work spout the different operators lke arithmetic, relational, Log asics of python and PyCharm code editor. asic Knowledge about operators Concepts I wanted the program to swap the values inthe varlable a and b ner a) The program” a) 30 id 20? Ces {po 90 000DD DOD 0 0 20 Questions (inetab): “What is operator? > gee are! ove speecat Nymbols tnt desta rare frit tevin perarton Soow a be pote a a goer vd 2. Whats pen 8? ts a dceumnenr that proufAe> qurde Urne¢ > pers on bo te wath® pylantode Bm pet practice “3, What is bitwise operator in python? Bition pinwftc operators Om ured tn peeieim mote Calwwatiore en Entegess Stomiented wate bineay format bir by pity “4. What is ternary operator in python? Feeney epesanoy gvatunte gometneng. bored a tendétio™ beim, eme(ory fable > S qythor, veston oS, prisadded ‘is python PATH? “qythen pans TPE (et spectol em routes guidance fo the python, tntenpeete eA? vob to dtnd — Uartous ttre} fp anptrtectior rue) PEE Aartobele eee) asks the user to enter two integers. Have the program output how many can be divided into the first number tonmesi tenants vecond number entered was 4 the program should report § tres i.e. the ‘you are required to implement this program using the floor operator. prorat second eure? was 73 nd the itis ignored Procedure/Proera™ tow ( frmux CH tmeen ons fonegia :"’)) sarCtmpart " enven of Gateqoos) te ao nequtk 2 mus \) rum o - corn Wet gruided Orta Bet Sane seyomnd rents fb awm is by " mAwdE 4 ‘yiones” Be fates ffort faregey <3 ; enter 0d tmrege 5 She decor = tun bot Cw he araided ‘aoe FS muro by 6 Sma ™ T Student 1D | | Student Name v rive: wort wath conditional execution and Looping statements rework with conditional like i and if else execution and Looping ; statements like ional statements like if, if. else and looping ut the different conditi ie loop statements. Joop and whl asics of python and PyCharm code editor. nal and looping statements Basic knowledge about Condition .e Factorial of a number. ip Python to display th Itiples of 7. to display the first 7 mul pn) def gartorfod (795 pail foe ge 7d ror gt C 2, 1 fo Fed attiem f° nx int(impart ) Point factort eel on >) pes oF Fi tm tapur’( “enter 0 digit" )) fy ft fn ron eC tem) 6 : ‘i . patra) OW Gy Be ari) a ~ Student ID 7 pb [Student Name ~ Se agra that accepts the lengths of three sides ofa triangle as inputs. The write a ot pate whether or tthe rangle aright rangle Real frm program out em that in aright tangle, the square of onesie equals the sum of a squares ofthe other two sides) python program to construct the folowing pater, using a nested for loop. write @ Procedure/Program: Beep maint s 3)? tmt ( tmpeer C)) tn ? par ( tmputc?) ty > imt( fmpure) ) fp pmyhtAmg eal toy): psotC teh orryeth sion’) Ase", yaint(” vot ert yevonyled Ganimyte” {kerr Anjled Ca bie ys OFF, eprtaae F a “ot pro : aan po (or ah a2 aD cant Student iD aie = Fi Student Name — | te she SIA fot” D tomr ong let foalnile. the J! » otter) . tnt (fapurt >) sty Tony & Coe ae . dot S tor wourgt Corie pormt( “H? ,and oe“ “) ptm tl). Dhow F fm oornge (79% 4 for jem crommpe (P): faint Cin? , ems") Pint C) ic Student ID | Student Name | ce questions (In-Lab): used to skip backto the beginning f a loop? ec Key wou" Sr refess ali the wemuinkr in Yor unsen — reaation 94 the loop bomM to the Wop Me hail!) \ keyword is used to end looping completely? pont fs ured tv ent loop tnny te cirnah weyers § pe What does the following loop do? It prints 1,2,3,4,5 and then exits it prints 1,2,4 then exits prints 1 forever gains } inyinthy rfarve For loops are used to loop over: HG ble wh fey | Student Name. print? for x in range(5): following code am ceompe (D7 dow 7 pon (rn), outpur ° 6 Z 4 & a rogram which accepts 2 sequence of comma Separated 4 ee ona Sesonns mn ; I + 0100,0011,1010,1001,1100, 1001 1010 Nalues~ £ J Be [xfes 2 TN Fyre) allt ; 0] Mow 5 i” num, ay got 4,2) mo ae: 4 7-8 * volues «append LP) pent ( sof c values) . = — Erp ON, toro, 100), wwe, 10087 1010 i [ STACK DEVELO! MAEM EAR: 2023-28 | Student 1D Student Name rile: worn wit USE ro ae slike append(0, insert() and remove() ., To Work apout the different lst method: with List processing method: Js ike append, insert , extend and remove, «Basics of python and pyCharm code editor. Basic knowledge about sequence datatype g values toa tuple of integer values. Go tothe editor i) Program to convert a tuple of strin tuple values: ((333° 33) (416°, '55') (1416, 55)) is Cruple — [tara 41S} “tes eenserl ( G0)47) point (usr) tft semsestl ye) petnrt ust’) kcpesemol tt. (1) grin (est) Lis prop 1?) pein |( ntle) pany Cust » Faken C109) pret ( BS cownr (23)) tS > some (1) pont ( wt) Usb reese CO) pont ( Ob) (q7 Usr~ topyly trfot ( (2) Ms bCleoe C) Prine C ust) ey Cranes yan) $1007" 234 pap envoy 234 co oa) ayy pro >*4 Bee 10/72)" puro 0 Student iD Student Name Questions (In-Lab): ce between List and Tuple- Tmanuiahle es we toe b Danone [hts at mutase > welowh) chomnet 2. What slicing in Python? surety ps the Unfsouton FRO pant test on ple PE SHANG, What is slicing in Python? > pynton A - Bcc tet 3g ante Meee ce) eA y © 7 Sane > L Perce) CP cs [a7 © ) ‘is indentation required in python? s Gadeniarton Bebe of statements ane novf spares researc Tn 0 books Of toAR js the difference between Python Arrays and lists? ternemts af arfrement ty p&S cine dora type vol wece Citecty eb step) moa motony i” pytnon to Ae fire. Student iO Student Name Sm convert a given string list to a tuple. ty, 't,'h, ‘o'r, '3', 8,0!) Procedure/Program: def aering - st auple (7 font em tet +0 tuple (i 3" not q python Bed fat (i) pernt Centng ost toruple C16 )) pant( type ctatag ust roveple (149 ]) Student 10 uh le petit ANY = *° Zions ‘st’? Py’, Rie, ty So fe tat, ty a) ZEA “euple” r Student 1D es Student Name snt Title: Working with Strings and Tuples To Work Strings operations and Tuples operations cs of python and PyCharm code editor. jic knowledge about text and sequence datatype. ogram to remove an empty tuple(s) from a list of Tuples. Sample data: [()()("), (abi), (a 'b {(d')] Expected output: [("), (‘2b’) (1, "b,c, d) a0) (.) (a Bt Ca ‘Bs men 69,62, Cr) f'a, 'B) pCa) fal] Bee [i fos yin st tt Gent Udit’) Cc'y) tb) 7 Ca, 8,0) 0) toreplace last valve of tuples in a list, Uist; [(10, 20, 0), (40, 50, 60), (70, 80, 90)] nd Output: [(10, 20, 100), (40, 50, 100), (70, 80, 100)} tery osha! 44v9 e ‘sat? sa syoy tte pote (s') qint 50441) ou pur cfyasa? su? Student ID Student Name EC rele!) ¢ (100, }fos bin west] nm te (Cte) Bo tov’) 4 0750/00) , (ro/t0/209] = es f Student | - . Student Name | —— will you convert a string to all lowercase? > tewts fsa bur’ tol -™ =python metho o peieran? Ly wed fo pean horndtt ny will you capitalize the first letter of string? > ht feat letres ep a sting Com be tape are satin Caprealt FEC) Aeentfon . are docstrings in Python? python AesenPbOm 4 Fn oo Shane wed D — dowwmen, e qytnon module, dow funttlen gar rnettocd, st are negative indexes and why are they used? pearve tnlemeng we fm pytnot to manfpulwe Seguené Opjters — SUUD OK Crit, aero, SPiayK tuple is faster than list? Program to count the number of characters (character frequency) in a strin, ' 1g. Sample ‘String: google.com Expected Result: {'g': 2, 'o': 3, ‘I: 1,'e': 1, woad { 3 fos prod. feeys + aver Feyst Te PF tn keyt. Arce C34 =!) met * ne easel ea) ettusn litt Baier ( Coven 1 (“google - ton") Student Name Title: Working with Dictionary and Functions. # To Work with Working with Dictionary and Functions parameters i: It identifies the dictionary creation, modification methods and Parameter passing sm using python in functions ‘© Basics of python and PyCharm code editor. * Basic knowledge about Functions and mapping datatype. script to concatenate following dictionaries to create a new one. Sample Dictionary: Result: {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60} Bye AraO, 2,204 Bp > (250, vtu0} Wz (ezs0 (100? dy update (Bo) Ay apdare C8) pnt ( 4) ) Ourput '.— Atsiv, 2020, 3430) y 407? SSP sbr809 = __biPython function that accepts a string and calculate the number of upper case letters and lower case letters. ‘Sample String: The quick Brow Fox’ Expected Output: No. of Upper case characters: 3 No. of Lower case Characters: 12 Ao chicas gett s dy-updute( 4p ) pint (45) Fo ‘ Oemt Ladrip buy, c's? , 208? $2 Inpate ) buez Qo: for ttm 3% tp fis lowes er? tel4\*, “EE Ft upper eye Srvasar eds in KLU Nip of uppecco4e cette! ih br oF tomes (O4€ totic’ 12 Student ID ___| Student Name | Questions (In-Lab): ‘a dictionary with some key-value pairs, what does a.popitem() do? an arbitrary element all the key-value pairs ss the key-value pair for the key given as an argument id method for dictionary ‘What will be the output of the following Python code snippet? test = (1:'A’, 2: st = {} print(len(test)) = 0 3, What will be the output of the following Python code snippet? >H "Error as the key-value pair of STACK DEVELOPMENT WITH DJANGO. SL [Page 62 of 225 | Student ID . Student Name ] SMe atre) at SM lOt to ued defined) — fern Hoy put without A Nowe They Ore Cormmonly ogereo) to OX funrttons per for wpe oper nto” 0 cre apolrd Bitertre care of tp) and dr function nPtnone CTY ore arony m0 maming yore tt help oy used to dtsplouy the detention — OF modules | futur, Ure 4 ey yore exc and metiaos BF voles Soleaty ttuen! OU property f a syecipeel} obs withour the n empty tuple(s) from a list of tuples. Sample data: [(),(),(".) ‘to remove at , tb), ('a','b','c),‘d'). d')] Expected output: dure/Program: tie fe) ; c*p tC ta), by) ca", ), Ca)] Ba. fee, te St mtd pent Crest ) ee 1 Co Kb} CO HHO s w] ‘|

You might also like