0% found this document useful (0 votes)
3 views1 page

Python Stack Operations and Functions

The document outlines a series of programming tasks involving stack operations in Python. It includes creating functions to push and pop elements from stacks based on specific criteria, such as student marks, employee salaries, and words without vowels. Each task requires the implementation of user-defined functions to manage and manipulate data stored in stacks.

Uploaded by

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

Python Stack Operations and Functions

The document outlines a series of programming tasks involving stack operations in Python. It includes creating functions to push and pop elements from stacks based on specific criteria, such as student marks, employee salaries, and words without vowels. Each task requires the implementation of user-defined functions to manage and manipulate data stored in stacks.

Uploaded by

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

STACK WORKSHEET

1. Vedika has created a dictionary containing names and marks as key-value pairs for 5
students. Write a program with separate user-defined functions to perform the following
operations:
1. Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.
2. Pop and display the content of the stack.
2. Write functions AddPlayer(player) and DeletePlayer(player) in Python to add and
remove a player by considering them as push and pop operations in a stack.
3. Write a program in Python, with separate user-defined functions to perform the following
operations on Stack 'City':4
(a) - Push the pin code and name of the city in the stack 'City'
(b) - Display the latest added element in the stack 'City'
4. Priyanka has created a dictionary 'employee_data' containing EmpCode and Salary as
key-value pairs for 5 Employees of Cyber Intratech. Write a program, with a separate
user-defined function, as mentioned below, to perform the following operations:
(a) push_emp(): Push all those EmpCode, where the Salary is less than 20000, from
the dictionary into a stack 'stk_emp'
(b) pop_emp(): Remove all the elements from the stack, one at a time, in a
Last-In-First-Out (LIFO) manner and display them. It also displays 'Stack is empty' once
all the elements have been removed.
5. Write a program in Python to input 5 words and push them one by one into a list named All.
The program should then use the function PushNV() to create a stack of words in the list
NoVowel so that it stores only those words which do not have any vowels present in them, from
the list All. Thereafter, pop each word from the list NoVowel and display the popped word.
When the stack is empty, display the message 'EmptyStack'.

You might also like