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

cheatstack

Uploaded by

hawk71443
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

cheatstack

Uploaded by

hawk71443
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

'''n=[]

top=None

def push():

x=int(input("enter the marks:"))

n.append(x)

top=len(n)-1

def pop():

if len(n)==0:

print("underflow")

else:

x=n.pop()

print(x,"deleted")

top=len(n)-1

def disp():

for i in range(len(n)-1,-1,-1):

print(n[i])

#_________________________________________________

a=1

while a>=1 and a<=4:

print("\n 1.push\n 2.pop\n 3.display\n 4.exit")

a=int(input("enter your choice"))

if a==1:

push()

elif a==2:

pop()

elif a==3:

disp()
else:

break

stu=[]

def pushstack(stu):

r=int(input("enter the roll number"))

n=input("enter the name")

m=int(input("enter the marks"))

rec=[r,n,m]

stu.append(rec)

def popstack(stu):

if len(stu)==0:

print("underflow")

else:

x=stu.pop()

print(x,"deleted")

def disp():

for i in range(len(stu)-1,-1,-1):

print(stu[i])

#************************************************************************

a=1

while a>=1 and a<=4:

print("\n 1.push\n 2.pop\n 3.display\n 4.exit")

a=int(input("enter your choice"))

if a==1:

pushstack(stu)

elif a==2:
popstack(stu)

elif a==3:

disp(stu)

else:

break

Grade=[]

def Push_Item():

n=input("enter the name")

a=int(input("enter the age"))

s=int(input("enter the salary"))

if s>=3000:

rec=[n,a,s]

Grade.append(rec)

def Pop_Item():

if len(Grade)==0:

print("StackEmpty")

else:

x=Grade.pop()

print(x,"deleted")

def disp():

x=len(Grade)-1

for i in range(x,-1,-1):

print(Grade[i])

#------------------------------------------

a=1

while a>=1 and a<=4:


print("\n 1.push\n 2.pop\n 3.display\n 4.exit")

a=int(input("enter your choice"))

if a==1:

Push_Item()

elif a==2:

Pop_Item()

elif a==3:

disp()

else:

break

status=[]

def Push_element():

n=input("enter the name")

pn=int(input("enter the phone number"))

c=input("enter the city")

if c=="BBSR":

rec=[n,pn,c]

status.append(rec)

def Pop_element():

if len(status)==0:

print("Stack Empty")

else:

x=status.pop()

print(x,"deleted")

def disp():
x=len(status)-1

for i in range(x,-1,-1):

print(status[i])

#-----------------------------------------------------

a=1

while a>=1 and a<=4:

print("\n 1.push\n 2.pop\n 3.display\n 4.exit")

a=int(input("enter your choice"))

if a==1:

Push_element()

elif a==2:

Pop_element()

elif a==3:

disp()

else:

break

stack=[]

l=[78,87,32,98,54,98,65,99]

def push():

for i in range(len(l)):

if l[i]>75:

stack.append(l[i])

def pop():

if len(stack)==0:

print("underflow")

else:
x=stack.pop()

print(x,"deleted")

def disp():

x=len(stack)-1

for i in range(x,-1,-1):

print(stack[i])

#--------------------------

a=1

while a>=1 and a<=4:

print("\n 1.push\n 2.pop\n 3.display\n 4.exit")

a=int(input("enter your choice"))

if a==1:

push()

elif a==2:

pop()

elif a==3:

disp()

else:

break

package=[]

def make_push(package):

k=int(input("new package:"))

package.append(k)

def make_pop(package):

if len(package)==0:

print("@underflow@")
else:

x=package.pop()

print(x,"deleted")

#-----------------------------------------

a=1

while a>=1 and a<=4:

print("\n 1.push\n 2.pop\n 3.exit")

a=int(input("enter your choice"))

if a==1:

make_push(package)

elif a==2:

make_pop(package)

else:

break

s=[]

ARR=[]

def Push(ARR):

a=int(input("enter the number"))

ARR.append(a)

for i in ARR:

if i%5==0:

s.append(i)

def disp(ARR):

if len(s)==0:

print("error")

else:
x=len(s)-1

for i in range(x,-1,-1):

print(s[i])

#--------------------------------------------

a=1

while a>=1 and a<=2:

print("\n 1.push\n 2.display\n 3.exit")

a=int(input("enter your choice"))

if a==1:

Push(ARR)

elif a==2:

disp(ARR)

else:

break

client=[]

def Add_client(client):

k=input("enter the name of client")

client.append(k)

def delete_client(client):

if len(client)==0:

print("underflow")

else:

x=client.pop()

print(x,"deleted")

#---------------------------------------------

a=1
while a>=1 and a<=4:

print("\n 1.push\n 2.delete\n 3.exit")

a=int(input("enter your choice"))

if a==1:

Add_client(client)

elif a==2:

delete_client(client)

else:

break

'''

You might also like