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

Python Assignment

Uploaded by

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

Python Assignment

Uploaded by

kikira9465
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 27
ASSIGNMENT Subject Code :- BCA-DSE1.1 Name of Subject:- Python Programming Course :- BCA Semester :- 5th (School of CA & IT) ‘Submitted by:~ Submitted to: ‘Name; Sahil Singh Name:- Mr. G.D, Makkar | no:- R210529054 i ACKNOWLEDGEMENT Tam deeply Srateful to my professor, Mr. G.D. Makkar, for their invaluable guidance and mentorship throughout the completion of this assignment. Their expertise and feedback Steatly enriched the content, and their dedication to fostering academic growth has been a constant source of Inspiration. T would also like to extend my appreciation to my fellow r Classmates for their collaborative spirit. Engaging in meaningful discussions and sharing ideas with them not only enhanced the quality of this assignment but also made the learning experience enjoyable and intellectually stimulating. Lastly, I want to acknowledge the unwavering support of my family and friends. Their encouragement and understanding provided the motivation needed to persevere through the challenges of this academic journey. | am thankful for their presence in my life, which has been instrumental in my success. “a T | _ |Pageno.| Sign | 5 ESS Analyze the differences between alist anda 4-6 tuple in Python? \ i rs a Evaluate the trade-offs between using various functions of inserting elements(s)inalist? | \ 3 |Illustrate list slicing to extract a subset of elements from a string 4 |Show how to use the sorted() and sort() | a Fe eeisane to sorta list of numbers in ascending | '"~” \ \ Va order 5 [Compare and contrast Python's for loop and | Hist comprehensions for creating lists. Provide. | 12-16 \ ‘examples e ae See 6 [Analyze the concept of short-hand Python's yyy | conditi al statements? | { 7 |Analyze the behaviour of functions that return | ; \\B-20 | multiple values? oe 8 [Develop a function that removes duplicates lg De items from a list while preserving the original. | VR order a sali aan 9 Explain in detail the concept of function parameters with example? Demonstrate set operations (unio! ection, difference, symmetri n, ic difference) Ql. Analyze the difference Ledaeon 9 Jrq ; ee ou. “— ’ MS:1. Multi > + lists. Lege ee \ \ ’ > f Co ’ nel . > * Tuples : 4 > > J > \ ; e , ; 3 a i elists list ore defn % Using Safvare bracki += 11,234] 0 * Tuple: Tuples ove defined by 400 ways (9) Using Fasontheses ‘Ly eg my-upke 0.2.32 ae (i). Wwhttout using Porontheses S. Pox eMance licks ore general because me 4 Use Case slists : eTuples : J My \ ° becouse cf ther at \ite Use of thet 4 de TORETCESELERELL SA B2. Evoluole te ade-offs bekveen using various Functions ch inserting elements) in @ fer? Ans. ). Appen dd Funclonalt ty « Tt + Trade: fs: \} Lo you want +o & Yoo nee tan be 2. Extend) * Functionality: The exe Clement ndl) foncken odds COCCI IIIT III 00 3. InsevtO): Phoneionality : i, di) »* Teade dh: lov) 4. Loncodenortion (+ opera - Fonchonalita + You F + Tt crtotes a nevd fre Trade -ofs Mince tongue Move Memore ¥ S S = Ss S = a) a) Ss a - oT ee 5. Shee Assignment * Functanalt/4: You can vse sticing Position Ly Y ‘ fred ntvol tam »Tyode- dfs : T+ pre dir 3 ting mulliple eloment veal 03. TMostile Itt stetry + extet a subset of men 4 with shing in Ans ) chayatte) fron EW { { , )iyehotion how to ose Tish the hing. Here's oF vation of esheet a. elements bom Qa a subset 6 shing +e Define Shing me _shing = "Hello, World’? 4 Basi list slicing sobebng mae Shing [9 #12) srerbratt pont Y AE Dmisting start ond end Index Bibbs = my-sting [8 trevtvact every, second valve bashing ) 4 Odpot "lo oll’ + Reversing a Shing Spbshing > ing sing pint (_Substing) +r Dulpks “Ldhow lel” _S\. aeReverses the enti PEER ITE INGIIIII09, Romer bey Qk Show haw 4 use the sovtedl ond sort) fonction 4, cot 0 list of numbers in ascending anlar Ans ordey fn hos o'6 + Using the ‘sortedlY Function The ‘sorledl Function xetns a new goxted fist widhrt modifiging the oviginal list. Here's on example ea Define Net d numbers numbers = £ 5,2, 9,1,5)63 He Use tho sowledl) tinction to @ +e Soiled list Using the sot) Hnekion . \ ot tre a Bile a 4 numbers H Numbers = dk Use the soxtl) method 40 EB H ascending ovder numbers. Sort 44 Print the Pather's fr loop ondl ligt 05. Lomport and lovtrast Lompahensions fos crtating liste. Provide cromples Ins. Both Patton's for bons ond Vist comp shen sions one vsed tov creating \igts , bot thea hove different purpose anal vse cases Veye’s a Lomparision and convost bebween the two , along woth “he exam ple. wprthension + concise ond ee compithension s ot 0 2 yodahle 92% 35 extol sts On expeession to cath Hn pprehensi epntsorie involves ¢ rf clerronk 4 @ Syntax AeSp1 = [ sorre-opention litem) fe (em) slem fo Theweble if sernt con Exam ple LUsing python list tomprthension +o generate even nombexs p at As © Tmmuto bility ‘ \ by elena ee p| For loops ove yergable ord should be used fox ComPler los and jis! Wont S Vinton s . loomplex conditions ox np|Hole statements Mays becernt fess wtadable shen condensed | Into a single \ine aaerrcceceteseeew +he behaviout wo \tiple values 2. Tuple Unpocking To cxccess fndividual volves r¢torned by o 4. Tmmvtability Ap 0 Rete te g ' ttain tHedy oviginal values and 4 1 ohets i 22K And “immuTanilits C 5, Tmplicit Tople Facking, Even 4 ypu clon’ explicit cueale a tuple tn tre sttom statement, Father implity ta ds &. Eweor Handling Fonelions webu moltple valves Qroking and enpatking one eficlens making it cowinient te work oan operations , molliple attorn wolves Use Case Moltiple vetuen valves ave ustfl ushen 6 needs fo provide welaked piece o, clote 7 [ p > > » » b ’ ) , , ) ' } / i \ abere finest } Defining Funedion Powomeses ae * Toxamerey! ds weet [nurne): print gy Yello, Xnarne | 5 HH name is poxamely and greet eo Dae Caling Aunctions wth Aygments def. goeet (nome- “huest”): print (F*Hello, {rare} overt) at Dulput + Hello, (nuest | Moliple Foxameleys Functions car bY, g def add (a,b) when orb yult = add (5) can pass de divdel dinderd, divisos) ! atin clividtnd/divisor aot = aide (dividend «10, divisev=2) bee ee STI ISSIILSLLZ. Ans. Sel operations fn python ort vce Various operations o7 sets. ae AE Define wo sets sed = 1,2 ,3,4,5% Sed = $45,6,4,8% 4b Union of te gots Lrion_rsplt = sett. urien (Se AE Simply using tw ‘| 0 Union végu|t—- alten 4k Under seror 4 inter sechonresul AE Difference between two sete, Aifesence —wesvlt = Sett Brox Simply ving the’ opeintor at Symebric difference berreen tuo s Atos simply using “he “P operato/ At Rind Result eaeeaiit CONS y difference — rewlt) mnmetric_ diffeente- resul i Difference ny 3. Difjrerrce $ 4. Syrnmeric Difference : find elements Of ets bu snlegettion. Use “Suummedica Differeneel Sex net fn they ot. ‘in the erthex Vow '® cperator

You might also like