0% found this document useful (0 votes)
46 views8 pages

Adobe Scan 23 Aug 2022

The document discusses implementing a stack data structure in Python using a list, including pushing and popping elements from the stack as well as removing a specified number of elements. It also provides an example of using a stack to track books added to a stack and later removed. The example demonstrates pushing multiple book names onto the stack and then popping a specified number off the stack.

Uploaded by

Sumit Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views8 pages

Adobe Scan 23 Aug 2022

The document discusses implementing a stack data structure in Python using a list, including pushing and popping elements from the stack as well as removing a specified number of elements. It also provides an example of using a stack to track books added to a stack and later removed. The example demonstrates pushing multiple book names onto the stack and then popping a specified number off the stack.

Uploaded by

Sumit Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

"

wotete Ppdho Dnoam mplement o sac


qucue uunga tst ata sdaructune
11
Im plemerdoaton cl slak usin Liut
Sh 1
ChaluJ
hile chol (a =
prit LOSE ")
Potint"2 Pop")
Point (3Display emets of dacr')
CintLinpt 'Eie jousu choiu"))
C =L
a int nput ("Enou-the. clemerst
elenent whih you
uon to push")
Siack apeno_
elt C2
Hstatk =[1
Paint Stack emot Lndet flod casecon'L
celel tka. clement
els
pint Dlele element i ", StaK Pop ()
eltr C=3
fo in Jange (len (stat) 1).
DIOREER
Page: 2

Dete

Patnt (sat [iJ))


else
Pint ibna input. )
choll inpud Doyou uan to continu or o
not2Gn)")
Braetcal - 8
tuatn

rcate a CsV t e b enlenig usen id oard


CSv
c thepasa f>n iven u:
erter and !à
cnt pasua>d: 1239

Contnue and N/n to nat pno


tD brminok impo CSv
t
thopcn CSv"u'',ncw une=)
N ilcbj nteou Use. la" Pasiwsrd
le(Tue)
erten ?ASuni
R S O S o l 9 9 9 9 9
QSe iA= inpt lerte id)
continu Cind NIn
to teirminta assun =inpt CenteI_password
Yy to
fh pcq m
iecoxd= luex- Jd paisuindT
le obuate aeeA
fD be seaT Chesd X= inpt CPeSK y t cerhous d
eler the Se id
NIn n 1eSimiinatihpytexmn)
ohamn Yin in N
S67 b1ea

CAtnu0
uula cpen (" f cCSy",' ")aahi2
CSV Jtacle sLlobj2)

next (fl obj2)


-BICRER
Teplc
actca Pege:
Date

Ot purt Coeaft a itBoo mplemeded astack &


a m t to PSH
n stack S n Cod to petem the ps nd pap
Hens y o
sta epexatton
How mnavy 0etne sRpeatu bnetons a earh pedtien
staunm
srt BooK=
t t e book nanme PHHSICS
depugH (term)
statk now
Sooks append (Hem
PASICs]
Ete book nanme
CHEMMSTRI prtsBaek aouln, Bank)
de Por SFASTACK).
Stack no
PHysCs,'CHEMSTPT
p t STALKmpG REmayEO)
Enten bcok name MATH
ne it nert CHow manu tem you
Stac ou wdh to a .
tatk)
TPHSICs HE mUTEi, "mATHS
ENLISH for in iang42(n)_
Ertea book ngmne
Stak now
bname mpt|Ender ook name)_
PUSb rome)
Prysies"cH EmSTRY,'MATn','ENGLISH'
CompUTER SCIENLE n25 nt (nputCHaw manyy itams qou
Emei booK namt und d pep
nom tatK'))_
Stac nod
PHYSICS,CHEMILTAY"MmATHS,ENCGLIsn,'WmputER SUIENE i n =len 8ook)
Ho many Hems You wont -ho Pop
tom Stack 3 in Menge (na)
COMpu TER SUENCE REMVED
ENGLSH gEMoVED ptintNow Contexts l atn,eBaos)
MAT HS REMOVED el
NEW Content of stak
Pryics CHEMMRRY
Bactica- to
D1onER*
Toprc Pa:

Oat

wtta a put
Output a file named
dt Cout and pnlat total words stant
wtha" in the Gle

ae
det cauxt- uona ():
ayan
Cnit
total uards staing uth 'a' ane 3
-open CC:Niagl alaaol
sors.tst'") Drave Desvrp

wnrd in inc. split+ 0:


g n d [0)== a)'
pxint luond)
pxint total woads stantinor
uneto Collino wth 'a'o u)
Count uosds 0
1onEL*-
pe: PractH (al-11
Dat

ogam o dad a n à diupoy thos tnca aoa


acton
l hoa endwth alghabetn'
adjoin
acemen A1-open°C:use. QoD One DleDesetup data
schovl
xt ")
Count=0

stri= file 1 seadlines )


Outpt
3
iim stoi
Number thes whith end wlth n' i1=='n':
Count t=1
pount Numbe o ines uhidh end
wh n=", Count)
lk.close )

You might also like