Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
20 views
9 pages
Python Assignment 2
Uploaded by
Indrajeet Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Python Assignment 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
20 views
9 pages
Python Assignment 2
Uploaded by
Indrajeet Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Python Assignment 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 9
Search
Fullscreen
QhulImeplnrcuiat Quwul Bats Implumutivg gut val way # in + yin: Codi? i e Clas quiet > | ap init. (self, sigtetoo)? selp-q = [Non] * Sixt Y : oe self. capacity = ° sey. front = 0 Setf. yeah =~ sett. count = 0 ay digurur (eelp): 1 eelpoihemply print (! unt Ondurflor') MPSBEOE UM tabs trie vad x= seth. q [sey front] prtnt (' Rumoving elumunt...” oO) : sel front = (self: frent +1) ¢/. oat self. counk = sett. wunt -] : rib x ; ‘ Ot enquire (self, valu) : TE eel}. toPut (): Paint (‘Overflord)* exit (-1) ot ) PAINE ( dnteating elunut sh rear = (self veare sdf 4 [redt. rear] sdf -ount = selt-cbuntAL display (oof) if self isémpty O° Paint (Tree quit is OmMP exit (1) Abu, colt. q [eel prove] ty’) at size (self): ruturn setf-count prink (Ts quiwe size at, 983) paint (1 Tu front elument 14’ q-diplay 0) FY daguere () Paint (TW pout elise uur, q-aiplay O) 4: daguiu () ‘ qdagquunt () soidiap tay.’ Output: Tnierting eum... | Interking eliment...2 Imouhng elumeut-- 3 Te quurt sizt Mh 3 The front elument iA |” Removing element | The brent elumint 1A 2 Removing element 2 Fie Removing clenant 3 Thr quiut th emptyQouwrdopununt dub And = Implinenting alist fm payed © Cods * ilist = (10,20, 30,40, Co ,66,10,801490, 100} paint Cluck: |) ilict ) paint ("Fivck elumint * + vlisetol) 3e res print (vRountk cununt 7, Lise 13d) print (ust clement fron 0 bo 4 index : PAInt (' 3rd or = 7h ; "ise 7) TList. append (111) : i: Sem : Print (’ List otter append O:'. (list) ag paint (inde ef \Bo\': |, iLisk. indsx (80) print Uofty pop Ls", list pops) foe tat - renove [o) Paint (‘apts munroving Bo: flit -imsert (2,100) FoRee ~ print (aftr fs ent: > CLUE NE om prink (‘numba 9 Decent o| Rion flat. extend CLI -22,333) ‘ 5 . é ees paint ("opty extending: ilist) : a Bey ig ilist- reverse U) “ogee prt (aptr rversinag 2" Llck i Oukput + ~ List : [10,20,30,40, or /60,10, 80,9 first elunwd = lo Founth elsmudt > 40 Uist elemunts from © to 4 fhSrd oy -Tin elinunt + 4o a fbr append )! [10,20 130,40, £0, 60/70, 6090, nda ag OFLU sorting: [10,20,30,40,60” Popped + [10,20 80,40, 0760/10/89) 90/108) 1 ,30,40,6 0 6070, 49/100 070,90, 90/1007 11) After vermoving’ Go!» [10,2 aftr iret. [ro,20, igo, 30) 40/00, 69-7019 00 ,cee 4 nuniber I Occunancu of hae 30,40, 00, Jo, 60,60 740,301 00) aft exlencling : [10,20, 100 60,70, GO, 100,123 Yt Aeversing : [3,22 W1V,100,904 Quts-3 Tarplnunt : i A= Impinuntyg arrout fn py ton: Coda: Tncpont OANGY Gt OA a-anm.onay('i', LI), 2,37) print ("Array before inseation | ") por tin ri (0,3): ‘ ij paint (aliJ, end" ") : peink () a-imet (1,4) paind (Array oft insertou: “) for i in (09. 7 prink (tL, end") print 0) print (First elununt fA- Usoalion) paint (1 Te popped elumunt iA : end ="") print (edva: pop?) Paint (" Tt aray cf ty Popping ws VeenJor i in yeunge (0,4): Paint [ati], end" ") Paint Une") b = an-anay ('0’, L1,2, 314i roy Tay paint ("Initial arrays”) : tor i in Cb): . PAu (0, Gnidss 2s) ‘ vor SUud-array = 6 [3:6] Punt ("\o sUcing elunten: in range 267 "y> Paint (stiad— ary ) ERE i Of2]=6 : print ("Array aftt updation (a): "end =" 3) for t in a): : ae paint (i ,end-) 9) Oulgules : ; eos Array before inbentton + 12 Beo st. ge ye Array Oftr Msertion + iH 2B 1 1: firet eluent id J gi nu popped eltnunk iA: 2 how hadqaq Tu anray aftr poppiag ts: 14 3 1 = Jnital anray: 12 GS bP INRA sUdng echimuntt in range ate. GOR Array affe, updation (a) » 14 6) = Cos :- Clam Nods : df — init — U8df too s dotadt push (suf aaa) ” 22 NOUl- iy celf. Waad * f celf yaad = Nod: (data) ear: nuono ce = Node (data) new nod nixt = selp wad self read > nuonodt ct pop (self): if selp.isemphy 0)" deb Now Qbrt poppednods = self-htad selt-luad = selp huad.nixt poppednodt -nixt = Nomy Subwur poppednods dara cf peek (sey): if sel. is Empty (): sutwur Nor Pe self -hrad data dy diplay (sel}): internods = selh lead TF seb isermply ©print (Stack Undtrflow') eat + tolgu Linkrnods | + Non): paint Cinkernods dala ,’-»" end 27 jnternods = internodu-ruUeh 2 fen ‘ —Nami — e¢ fe main’ Ry stack () = Stack ©) i on My cha uk puch (i) ‘ -¢ My Stack - puth (22) yes Ny shack push (33) My stack path (44) Mystack diiplouy ©) ee print (' Top elumenk 14 es een), Hystack -pop U? fie Mystack pop mystack display 1) JPR KE! Pees Nee paint (Top elemunt iA”, ty ckack peek ©) Outputs 44 337222 211-7 Top ehummt i444 22-91 Top elumunt 14 22 Qu-© vAing Unkad 2b implee “ved fnbuild func owt oh Avu: dnnplumunk ng quan uringsel. data =data sult nixt = arxt Clam Unkrd List : clit Smite (elt) Seu bwad = Nom Aub invert (seep clara): NUdNodt = Nodu (dara) TE (setf- vead): cwvunt = self: bead wi Counnrent ext) * current » wurrent wok euend wut = rus nod ehh. usd 2 uanodt dt rentove (self) * temp = sett liad if Ctemp ia not Non) * Clr = tenp data sult ledd = temp wixt temp = Nov pub elem det peek (sey): if (sey tad): current = self. Lead wl L Cetrro -Moxt)* cuit = cunt MOE rotw0our wuvunt -daka : out print Lt (seit): cunt = sett- brad wld Cowunt) : | Pant Cearrint data) : out = CULE, Wh SaQurut = Unkedlict 0) Qu inert (3) Point (lelenunt at bu tail uM, Queut- peek )) Qururs insert (4) : paint (i @lumuint ar Hu baile RuCl ieee Qua insert (©) | paint ("es F darquiud 2), Quite Auwove O) print (“Quur aft, duletion +". uuu + Output :- e@umeunt at Hu tail: % Plinunt of Hu tail + 4 Pumint diquiurd » 3 Quit aftr diltHon: 4 5
You might also like
Python Cheat Sheet PDF
PDF
No ratings yet
Python Cheat Sheet PDF
26 pages
100 Helpful Python Tips You Can Learn Before Finishing Your Morning Coffee | by
PDF
No ratings yet
100 Helpful Python Tips You Can Learn Before Finishing Your Morning Coffee | by
108 pages
Python Programs
PDF
No ratings yet
Python Programs
16 pages
problem solving and python programming
PDF
No ratings yet
problem solving and python programming
34 pages
Week 7 leacture
PDF
No ratings yet
Week 7 leacture
73 pages
PDF Scanner-07_03_2025-04_36_47
PDF
No ratings yet
PDF Scanner-07_03_2025-04_36_47
48 pages
python prgm
PDF
No ratings yet
python prgm
51 pages
Exception Handling, Python Data Structures
PDF
No ratings yet
Exception Handling, Python Data Structures
18 pages
UNIT 5 - Mutable Data Structure
PDF
No ratings yet
UNIT 5 - Mutable Data Structure
46 pages
mpmc1
PDF
No ratings yet
mpmc1
20 pages
Python
PDF
No ratings yet
Python
31 pages
Python Lists by Vipin Bhai
PDF
No ratings yet
Python Lists by Vipin Bhai
26 pages
Pps Notes
PDF
No ratings yet
Pps Notes
67 pages
Unit 2
PDF
No ratings yet
Unit 2
30 pages
Dsa Unit 2 Notes
PDF
No ratings yet
Dsa Unit 2 Notes
35 pages
Python Programs
PDF
No ratings yet
Python Programs
25 pages
New Doc 03-29-2020 12.21.34
PDF
No ratings yet
New Doc 03-29-2020 12.21.34
23 pages
DSA chp-4 - English
PDF
No ratings yet
DSA chp-4 - English
21 pages
124111029_sai_srikar
PDF
No ratings yet
124111029_sai_srikar
18 pages
computer-PROGRAMS-A2Z-XI
PDF
No ratings yet
computer-PROGRAMS-A2Z-XI
19 pages
Python Review Code
PDF
No ratings yet
Python Review Code
26 pages
Adobe Scan Sep 29, 2024
PDF
No ratings yet
Adobe Scan Sep 29, 2024
25 pages
Python 4
PDF
No ratings yet
Python 4
11 pages
Chapter 2 (DS)
PDF
No ratings yet
Chapter 2 (DS)
50 pages
Java1 5
PDF
No ratings yet
Java1 5
19 pages
Kajal Soni IPE Data Structure
PDF
No ratings yet
Kajal Soni IPE Data Structure
17 pages
Python List
PDF
No ratings yet
Python List
10 pages
Programs For Dsu Manual
PDF
No ratings yet
Programs For Dsu Manual
15 pages
Unit 2: Expressions and Variables For Loops
PDF
No ratings yet
Unit 2: Expressions and Variables For Loops
15 pages
python basics
PDF
No ratings yet
python basics
13 pages
DSA Lab Sheet
PDF
No ratings yet
DSA Lab Sheet
33 pages
Python Assignment 2
PDF
No ratings yet
Python Assignment 2
12 pages
AI Practical Assignments
PDF
No ratings yet
AI Practical Assignments
12 pages
Important Topics
PDF
No ratings yet
Important Topics
12 pages
2026 Phy 25 Marking
PDF
No ratings yet
2026 Phy 25 Marking
6 pages
Array - Notes
PDF
No ratings yet
Array - Notes
24 pages
Omaiyuva Mo Sindhaiyu Nani ?
PDF
No ratings yet
Omaiyuva Mo Sindhaiyu Nani ?
10 pages
Final Mock Solution
PDF
No ratings yet
Final Mock Solution
8 pages
Adobe Scan 15-Dec-2023 (1)
PDF
No ratings yet
Adobe Scan 15-Dec-2023 (1)
8 pages
Week2-Day3(28-05-2025)
PDF
No ratings yet
Week2-Day3(28-05-2025)
6 pages
Functions in C ?
PDF
No ratings yet
Functions in C ?
11 pages
Unit 4 Final
PDF
No ratings yet
Unit 4 Final
20 pages
dsa
PDF
No ratings yet
dsa
9 pages
Computer Work
PDF
No ratings yet
Computer Work
42 pages
cs practice
PDF
No ratings yet
cs practice
5 pages
CSE 1001 (Python) Faculty Name: Dr. AMIT Kumar Tyagi
PDF
No ratings yet
CSE 1001 (Python) Faculty Name: Dr. AMIT Kumar Tyagi
16 pages
UNIT-2
PDF
No ratings yet
UNIT-2
15 pages
all time favourites 1
PDF
No ratings yet
all time favourites 1
3 pages
Practical Python Programs
PDF
No ratings yet
Practical Python Programs
3 pages
Python
PDF
No ratings yet
Python
5 pages
Supermind 4 Unit 9 Exercise
PDF
No ratings yet
Supermind 4 Unit 9 Exercise
8 pages
St. Xavier's College: Python Language Lab
PDF
No ratings yet
St. Xavier's College: Python Language Lab
13 pages
Ch7 Lists
PDF
No ratings yet
Ch7 Lists
3 pages
Quick List and Tuples Examples Python
PDF
No ratings yet
Quick List and Tuples Examples Python
3 pages
Computer Science Practical Amit Bikram Mishra Class Xii Science A
PDF
No ratings yet
Computer Science Practical Amit Bikram Mishra Class Xii Science A
18 pages
Fast Review Midterm Compilation
PDF
No ratings yet
Fast Review Midterm Compilation
8 pages
Cremesc16 Minnie
PDF
No ratings yet
Cremesc16 Minnie
8 pages
PythonGuide V1.2.9
PDF
100% (2)
PythonGuide V1.2.9
2 pages