Introduction to Stacks in python, Study Guides, Projects, Research of Computer science

Introduction to Stacks in python

Typology: Study Guides, Projects, Research

2025/2026

Available from 01/24/2026

abhishek-voi
abhishek-voi 🇮🇳

5 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MULTIPLE CHOICE QUESTIONS (MCQs)
1.
What is the principle followed by a Stack?
A.
FIFO
B.
LILO
C.
LIFO
D.
FILO
2.
In Python, which data type is commonly used to implement a stack?
A.
Tuple
B.
Set
C.
List
D.
Dictionary
3.
What will happen if a POP operation is performed on an empty stack?
A.
Overflow
B.
Underflow
C.
Top Element Removed
D.
Nothing Happens
4.
Which of the following is NOT a real-life example of a stack?
A.
Bangles worn on wrist
B.
Queue at a movie theatre
C.
Pile of books
D.
Stack of chairs
5.
Which method in Python list is used to remove the top element in a stack?
A.
remove()
B.
del()
C.
pop()
D.
discard()
6.
In infix expressions, where are the operators placed?
A.
After operands
B.
Before operands
C.
Between operands
D.
At the end
7.
What is postfix notation also known as?
A.
Forward Polish
B.
Prefix
C.
Infix
D.
Reverse Polish
8.
Which function checks if a stack is empty?
A.
isEmpty()
B.
emptyStack()
C.
checkEmpty()
D.
None
9.
What type of error occurs when trying to push an element into a full stack (in languages with
fixed stack size)?
A.
Syntax Error
B.
Runtime Error
C.
Overflow
D.
Underflow
10.
What would be the result of evaluating the postfix expression: 7 8 2 * 4 / +?
A.
15
B.
11
C.
14
D.
10
pf3
pf4
pf5

Partial preview of the text

Download Introduction to Stacks in python and more Study Guides, Projects, Research Computer science in PDF only on Docsity!

MULTIPLE CHOICE QUESTIONS (MCQs)

1. What is the principle followed by a Stack? A. FIFO B. LILO C. LIFO D. FILO 2. In Python, which data type is commonly used to implement a stack? A. Tuple B. Set C. List D. Dictionary 3. What will happen if a POP operation is performed on an empty stack? A. Overflow B. Underflow C. Top Element Removed D. Nothing Happens 4. Which of the following is NOT a real-life example of a stack? A. Bangles worn on wrist B. Queue at a movie theatre C. Pile of books D. Stack of chairs 5. Which method in Python list is used to remove the top element in a stack? A. remove() B. del() C. pop() D. discard() 6. In infix expressions, where are the operators placed? A. After operands B. Before operands C. Between operands D. At the end 7. What is postfix notation also known as? A. Forward Polish B. Prefix C. Infix D. Reverse Polish 8. Which function checks if a stack is empty? A. isEmpty() B. emptyStack() C. checkEmpty() D. None 9. What type of error occurs when trying to push an element into a full stack (in languages with fixed stack size)? A. Syntax Error B. Runtime Error C. Overflow D. Underflow 10. What would be the result of evaluating the postfix expression: 7 8 2 * 4 / +? A. 15 B. 11 C. 14 D. 10

11. Which operator has the highest precedence in arithmetic expressions? A. + B. - C. * D. = 12. In the conversion of infix to postfix, where are the operators stored during processing? A. Queue B. List C. Stack D. Array 13. Which function is used to read the topmost element from the stack? A. pop() B. top() C. peek() D. get() 14. What is the output of the top() function when the stack is empty? A. 0 B. Error C. None D. Null 15. What is the postfix equivalent of the infix expression (x + y)/(z * 8)? A. xy+z8 / B. +xy z8/ C. /+xy z D. x+y z/ 16. Which of the following is a valid use of stack in text/image editors? A. Spell check B. Redo/Undo C. Save file D. Crop image 17. Which stack operation returns the number of elements? A. size() B. length() C. count() D. getSize() 18. During infix to postfix conversion, what happens when a right parenthesis is encountered? A. It is ignored B. It is pushed to stack C. Operators are popped till left parenthesis D. Nothing happens

Assertion (A): Overflow condition occurs when an element is inserted into a full stack in Python. Reason (R): Python lists have a fixed size and cannot grow beyond a limit. A. Both A and R are true, and R is the correct explanation of A B. Both A and R are true, but R is not the correct explanation of A C. A is true, but R is false D. A is false, but R is true 26. Assertion (A): Infix expressions are easy for humans to read but difficult for machines to evaluate. Reason (R): Infix expressions require knowledge of operator precedence and parentheses handling. A. oth A and R are true, and R is the correct explanation of A B. Both A and R are true, but R is not the correct explanation of A C. A is true, but R is false D. A is false, but R is true 27. Assertion (A): In postfix notation, parentheses are not required. Reason (R): Postfix notation places operators in a way that respects operator precedence inherently. A. Both A and R are true, and R is the correct explanation of A B. Both A and R are true, but R is not the correct explanation of A C. A is true, but R is false D. A is false, but R is true 28. Assertion (A): While converting an infix expression to postfix, operands are pushed onto the stack. Reason (R): The stack is used to hold operands and not operators. A. Both A and R are true, and R is the correct explanation of A B. Both A and R are true, but R is not the correct explanation of A C. A is true, but R is false D. A is false, but R is true 29. Assertion (A): In evaluation of postfix expression, operators are pushed onto the stack. Reason (R): Stack helps evaluate binary operators from left to right. A. Both A and R are true, and R is the correct explanation of A B. Both A and R are true, but R is not the correct explanation of A C. A is true, but R is false D. A is false, but R is true

Assertion (A): Stack is a helpful structure in browser history navigation. Reason (R): The back button uses LIFO mechanism to navigate to the previous pages. A. Both A and R are true, and R is the correct explanation of A B. Both A and R are true, but R is not the correct explanation of A C. A is true, but R is false D. A is false, but R is true

FILL IN THE BLANKS

1. A is a linear data structure in which insertion and deletion are done from the same end. 2. Stack follows the principle, where the last element added is the first one removed. 3. In Python, a stack can be implemented using the data type. 4. The operation to insert an element into a stack is called. 5. The operation to remove the topmost element from a stack is called. 6. Attempting to remove an element from an empty stack leads to condition. 7. In stack implementation using Python list, elements are added using the method. 8. The function in stack returns the number of elements present. 9. The function retrieves the most recently added element without removing it. 10. The postfix expression of (x + y)/(z * 8) is. 11. Infix notation places operators the operands. 12. Postfix notation is also called notation. 13. During infix to postfix conversion, only are pushed onto the stack. 14. In evaluation of postfix expression, only are pushed onto the stack. 15. The isEmpty() function returns if the stack contains no elements.