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

Stack Assignment 1

Uploaded by

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

Stack Assignment 1

Uploaded by

abhinavrsingh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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

You might also like