0 ratings0% found this document useful (0 votes) 4 views8 pagesPython Week 10
PYTHON WEEK ASSIGNMENT SOLUTION
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
Date: o6la2|23
Page No.: 40
Title : leek Ls
Programe o Shoals snardgaQnnen
Progxom on Stacks
dave Stack :
def —-kt —— Coelh) ¢
sell. thema = (eal
dele {sary Codi);
~wetuan len Ceelly item )==0
del pusb( tell ithers) $
sel, Sere soppend.
pot CF" pure 4 remy ents Lhe gkack")
Ach pple) *
UW nek sally {samp cy:
popped hem = sell eee POPC
Print (£% popped Lpsrped eh
relay popped aber
else ¢
piot CS Shack is empty “)
Crem)
Leon the stack]
del. peels Cset,) %
tL not Selly vis- amply en
wenn olf items C4]
elses
phe stack *% empty")
del displny Csetty):
he nok seth st —emply C7!a:
Back operations :
2 Roh
2° Pop
3+ Peek
+ Biepley-
5: Bit
Bole your chute Ca-B TL
Enter the Stern to push eke the stack $2
pushed 22 ako the stock
Shock operations g
4 Push
2+ Por
3+ Peck
4 Oheg
5: Bek
Soler yoorchotee (4-5 L
Emtec -the Hen te poh ots
pushed act oto the skacls
the shock 2 2+
shack Operrations |
4- Caso
2 Pop
B+ Peek
4-0
et
Enler your choice C45) PL
Enter the Her te pus onto the Shock: 54
pushed 5+ onto “the stack
gkack operotionr 3
4+ asl
2+ Pot
5: Peek
ips Dig leyDate :
Page No.: 44
Poe C * Shack clemeaty : MH) ell .$ )
else?
phot CS Stack ts empty)
Title
stack = Stack C7
pile Tue !
prot CS \n Shack Operation +)
prot (4+ Pah”)
paot C* 2+ Pop*)
eaot (3: Peek")
prist (28 Diiplog *)
phot C* 5 Exth *)
che = free C¥ Ent your chotee (+5) 3")
Yip chtce == 848
Shem = Ropu ( * Enlex the thenn to push wnto the Stack ;)
Stack + pushy (tlem)
eM chsce == Wat?
Skack: pep o>
ee choke == “a's
peeked —tern= stack: peak C )
POLE ES Tap clement | { pected Alem)
aby choke == Qt g
Stack « Aisplng op)
ali choice == ts"?
pot C* Eating the pry: Gpodleoye oD)
Toweclk
RC A Kpvebieh chetce- Please enter a number dard 5-") :BGR
Sokex Your choice (4-53 >
Paped 5s berm Abe stack
Stock operation 3
a-Push
2+ Top
3+ Peck
ae Oteqloy
Se Exit
Boer youe ohhice (4-5) 3
Top element $24
stack Operactione 3
4+ Rusk
2 Ry
B+ feck
A Preplog-
5+ Gite
Ente pee see (4-53 +
Stark lemaste ¢ CS ia!, Vogt)
Stack Operation :
4: Push
Qe Pop
3 Peek
4 Dig!
5s Bat
Enter you choke C4 -s)85
ta the Rare” . Spec ye |Title : Date :
Page No.: #2
Progr 5 Queues
claws Quene 2
del ——it --Cselh) $
sel\hettems = 09
el, Xs —amptoy Cel, )*
wekwun len (self there) = =0
del enqueve (se\h 4 them) t
sell Terry append Cite)
pat (es Enquoued (tem foto the quene®)
dc Aeqene Csely)!
Alp wok sev, As empty @\:
dogue wed fers = self, stems « pap Co)
pet C fe Dequened, { dequerred tem Vromthe opseue *)
wenn cequerect artery)
else 2
pat (+ Quene 8 empty #)
del frmot C sell):
YE vot oleae oe
motu selfs lems Co]
else :
pat Ch Queene ts erp ty)
del soled Col):
tty wok sell \s—empby C93
pot Co @uene elemente #") sellpeikeme )
ele:Sue §
Quowe Operarbions §
4+ Enowene.
2+ Dequene
3+ Feo
4+ Disp
Seat “d
Sole, your choice (4-5)i 4
Enter the tinm oO enoprene goto the quent 4o
Enopauad 42 foke the ene
p ... Opersokiony :
As Enquene
2+ Dequene
3+ Peeot
a Bune
BR
Bolen choice (4 -B IL
Di be tern te exewane. Rete the Cuaies
Enqpered 25 foo! the: Wee
Queve Operations i
4 Enquene
2+ Dequene
3: Font
a& het
B- Sit
Geter Your chaice, GER) Se
Rite tengo eee me ee Lo
dnonened £0 is he qpeue
Quene Opecateionk $
A+ Goquene
D+ Dequene
5+ Front
ae Dtsploy-Date :
itle :
: Page No. : 4-3
poet C* Quene Xs empty 0)
ope = Quene CD
while Tre é
patot (“to Qaene Operations ; *) %
pave (8 4: Engquene Ww
past (42 Oequene “)
pint C+ 3. Front ">
pmEC" ¢- Otspley ")
Poot C8 5 eit 8)
White = tomate (levee en eee
ty ed a ie e Cis ) 3")
Ferg = fnput C * Got the Nerts enquene Ratconthe ques)
Bee 5 enaysen caer)
ely chite == 824?
qwenes dequeue CD
aly cheice == Segue
trot them = quene: front ©)
pee CE treat clement tL font —fen}* )
at ches =14 "2
Qpeues Aieplay C7
ely chotes = 5 "5
Pret Cea the Program: Geoclbye | )
beoak
ele ¢
pot C* Sawalid Chote: Please enter a rember betwee
soa oD)_
Bs BRE
Co chafcee C 4-5 )22
Dequened 22 trove the exe
Queue Opesationr |
4s Eroyrene.
2+ Dequene
3+ Fam
te Dteplay, @
Be Exit
faery choice CA-5) 33
Faowt eclernent $24
Quene bperation: g
As Enquene
2+ Oequene
3. Front
ae Diode
5: Sit
Sols Your Peotone oa.
Queue eleronte + Lot's Vol
Queue opercet tons :
A+ En qeue
2 Denpene
Be Foot
a Dieplog
5+ Ett
Bolen yor hate Case
ce the pregrore: Goodbye!