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

Python Week - 10

Python programming

Uploaded by

abdul7ahad73
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)
15 views

Python Week - 10

Python programming

Uploaded by

abdul7ahad73
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/ 5

INDEX

S.No. Date Name of the Experiment Page No. Remarks

Week : 2
Programs on Tnherntance
and PolymorphtSm

/s l24
on stacks and
Frogams
Queues
Ttle :
Date: 27lo3l2t
Page No: 12
Output: PROGRAr1S ON STACKS NO QUEUEs
1. Push
2. POP 1. Python programn to tmplerment stack
3 PeekK
#Stack
41splay def push (1):
S Cuit
data int (input ((Enter the value:)
Entr n:1 S. append (dato)
Entr the value: 10
1. Purh def op():
2. Pop if lenl) 0:
3. Peek print (stack is underflow)
else :
print (" The seletd element i
énttr n:
Cn ter the val ue : Jo
def peek0:
(f (en()= 0:
1.Push
print (^ Stack tr underflo)
3 Pee else:

4.s1play print("The top elerment of stack :" s0)


SEnlt
Cntr n:1 def ctsplay ():
Entey the value : 30
1. Push print ("stack is unda flow)
2. Pop else:
3.Peek
4- D0sp ly
print ("The Stack elernentt are :", stack)
En tey n:2
The Aelettd elemtrt : so
1.Ath bale Il6la4

3 Ftek

Ihlle (1):
Gnttr n:3
20 prtnt1.ush\n3 Po/n3.feern4 Diplays Calt")
he tep tlenent ef stax n lot (rput("cotr n:))
1ush
3 Peek puch (stac)
4. Aitplay elrr (n2):
PoP(stack)
Cnttr n: 4 eli( (n:i):
Ihestack elemenh at: Peek (stack)
J.push ellf (n: 4):
3. Peek ditploy (nack)
4. AIplay eur (n: ) :
exit (o)e
en ter n: S
Date: 2?logl 2024
Title:
Page No.: y
Output: 2. Pythorn prugramn tb imple ment @ueue .
1. EnQueue #@ueue
e Quene def Enucuc (4):
3 Peek data : lnt (nput ("enter the value: ))
4- Aplay 4 append (dlata)
S Gt
def edueue (a)
Enter
érr your cholte:4
10
En ttr the vale :
1. en@uee
print ("@ueue s underflow)
tlse:
R e @ue ne
print ("Bele ted element is:" 2Poplo)
3. Peek
def peek(q):
f (en(a) :2 0:
éntr yout choice: 1 print ("aucue i! urderfloo )
else:
Gnttr the value : 20
1. En Quene
print( The frtt elernernt of quene i:"0)
def diiplay (a):
3. Peek if ten():= 0:
print/^ Queue Is undeyflow)
Senit
print (4)
Gntr your chol le :1
enter the value:30 #Arier Code
i.énOuee
queue C]
J e Quee
JIhile (2):
3.Peek
print(4ndueue v2 Dequeue\ns. Peck\n4. Driplay in s. fatt')
Si east. n: tnt (nput(entr your cholre :))
Title :
ypuY chotte : a
enter your
Sclettd element !: 10
1. enQuee nQue uclaueu)
3- Pee
De@ueue (q ucue)

Enter your choice :3 peet (aueue)


The Ant elenet of queue ( s i s 3
1.En Queue display (qucnc)
Q e@ue e
2. Pect Crit lo)
4. splay

entr your Choice :y

1. Enuene

3.Peek

Gntr your chbrce : s

You might also like