PROGRAM 1-1
PROGRAM 1-1
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in N:
if k>33:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break
YASH MOTORS have a dictionary of top performer EMPLOYEES
and their SALES of as key value pairs of COMPANY. Write a
program, with separate user defined functions to perform the
following operations:
For example:
If the sample content of the dictionary is as follows:
SALES={"SUNIL":700000, "ROHIT":400000, "RAJEEV":350000,
"MAYANK":750000,"RAHUL":1000000, }
The output from the program should be:
SALES={"SUNIL":700000, "ROHIT":400000, "RAJEEV":350000,
"MAYANK":750000, "RAHUL":1000000 }
def PUSH(STK,S):
STK.append(S)
def POP(STK):
if STK!=[]:
return STK.pop()
else:
return None
ST=[]
for k in SALES:
if SALES[k]>500000:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST), end=" ")
else:
break
Saroj have a list of 10 numbers . You need to
help him create a program with separate user
defined functions to perform the following
operations based on this list.
For example:
If the sample content of the dictionary is as follows:
SETUP={"HR":10, "QUALITY":25, "SUPPORT":50,
"PRODUCTION":20, "SUPPLY":25,}
The output from the program should be:
SETUP={"HR":10, "QUALITY":25, "SUPPORT":50,
"PRODUCTION":20,"SUPPLY":25, }
def PUSH(STK,S):
STK.append(S)
def POP(STK):
if STK!=[]:
return STK.pop()
else:
return None
ST=[]
for k in SETUP:
if SETUP[k]>=25:
PUSH(ST,k)
while True:
A programmer wants to prepare a stack from given list
of integer elements only for the numbers which are
divisible by 3. Help him create a program with a user
defined functions to perform the following operations
based on this list.
For Example:
If the sample Content of the list is as follows:
N=[3,5,10,13,21,23,45,56,60,78]
Sample Output of the code should be:
N=[3,5,10,13,21,23,45,56,60,78]
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in N:
if k%5==0:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break