0% found this document useful (0 votes)
10 views2 pages

Python Imp Commnd

Uploaded by

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

Python Imp Commnd

Uploaded by

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

s= []

top = None
def isEmpty(stk):
if(stk==[]):
return True
else:
return False

def push(stk,item):
stk.append(item)
top = len(stk)-1

def s_pop(stk):
if(isEmpty(stk)):
return("Underflow")
else:
i=stk.pop()
if(len(stk)==0):
top=None
else:
top = top-1
return i
def s_peek(stk):
if(isEmpty(stk)):
print('Stack is empty')
else:
top = len(stk)-1
print(stk[top],'<-----top')
for i in range(top-1,-1,-1):
print(stk[i])
while True:
print("Stack Implementation")
print('1. Push')
print('2. Pop')
print('3. Peek')
print('4. Display')
print('5. Exit')
ch=input(int("Enter the choice(1-5)"))
if ch==1:
item=int(input('Enter the item you want to push:'))
push(s,item)
print('%d added successfu;;'%item)
elif ch==2:
item=pop(s)
if item=='Undeflow':
print('Underflow Stack is empty')
else:
print('%d is popped'%item)
input('Press any key to continue...')
elif ch==3:
item=pop(s)
if item=='Undeflow':
print('Underflow Stack is empty')
else:
print('%d is popped'%item)
input('Press any key to continue...')
elif ch==4:
display(s)
input('Press any key to continue...')
elif ch==5:
break
else:
print('Bhai tu thoda sa andha hai kya?')
if (stk==0):
return True
elif (stk==1):
return True
elif (stk==2):
return True
elif (stk==3):
return True
elif (stk=>4):
return False
a=[10,23,56,[78,10]]
b=list(a)
a[3][0]+=17
print(b)
lst1="Hello"
lst2=list((x.upper(),len(x)) for x in lst1)
print(lst2)

You might also like