S TACK ASSIGNMENT 1
A School has created a dictionary containing top players and their runs as key
value pairs of cricket team. Write a program with separate user defined functions
to perform the following operations:
(a) Push the name of the players(Keys) of the dictionary into a stack, where the
corresponding runs (value) is greater than 49.
(b) Pop and display the content of the stack.
Data = {'Rahul':40,'Gaurav':55,'Ritik':80,'Shivam':90}
stack = []
def push()
for i in Data:
if Data[i]>49:
[Link](i)
print("players whose run is more than 49")
print(stack)
push()
def pop1():
for i in Data:
print([Link]())
print("initial stack is")
print(stack)
pop1()
Output
players whose run is more than 49
['Gaurav', 'Ritik', 'Shivam']
Shivam
initial stack is
['Gaurav', 'Ritik']
Ritik
initial stack is
['Gaurav']
Gaurav
initial stack is
[]
KEET 12 TH