Completed
Stack - Concepts
Questions From This Challenge
Q1mcq1 mark
What does the acronym LIFO stand for, which describes the fundamental principle of a stack data structure?
Last In First Out ✓
Last In Final Out
Least In First Out
Last Index First Out
Q2mcq1 mark
In a stack implemented using a Python list named `stack`, which method call correctly performs a 'push' operation to add the value 25?
stack.append(25) ✓
stack.add(25)
stack.push(25)
stack.insert(25)
Q3mcq1 mark
In a stack implemented using a Python list named `stack`, which method call correctly performs a 'pop' operation and removes the topmost element?
stack.pop() ✓
stack.remove()
stack.delete(-1)
stack.pop(0)
Q4mcq1 mark
When a Python list is used to implement a stack via append() and pop(), which end of the list represents the 'top' of the stack?
The end (highest index) ✓
The beginning (index 0)
The middle element
Both ends equally
Q5mcq1 mark
A stack is implemented as `stack = []`. Which expression correctly checks whether the stack is empty?
len(stack) == 0 ✓
stack == 1
stack.pop() == None
len(stack) == 1
Q6mcq1 mark
If `stack = []` and `stack.pop()` is called, what happens?
IndexError is raised because the list is empty ✓
It returns None silently
It returns 0
It returns an empty list
Q7mcq1 mark
Which expression lets you 'peek' at the top element of a stack `stack = [5, 10, 15]` without removing it?
stack[-1] ✓
stack.pop()
stack[0]
stack.top()
Q8mcq1 mark
A stack starts empty. The operations push(10), push(20), push(30), pop() are performed in order using a Python list. What is the top element of the stack after these operations?
20 ✓
30
10
The stack is empty
Q9output1 mark
What is the output?
stack = [] stack.append(10) stack.append(20) stack.append(30) stack.pop() print(stack)
Correct output:
[10, 20]Q10output1 mark
What is the output?
stack = [] stack.append(5) stack.append(15) stack.append(25) top = stack.pop() print(top)
Correct output:
25Q11output1 mark
What is the output?
stack = [1, 2, 3] stack.append(4) stack.pop() stack.pop() print(stack)
Correct output:
[1, 2]Q12output1 mark
What is the output?
stack = []
for i in range(1, 5):
stack.append(i * 10)
stack.pop()
print(stack)
Correct output:
[10, 20, 30]Q13output1 mark
What is the output?
stack = [7, 14, 21] print(stack[-1], len(stack))
Correct output:
21 3Q14output1 mark
What is the output?
stack = []
stack.append('A')
stack.append('B')
stack.append('C')
print(stack.pop())
print(stack.pop())
print(stack)
Correct output:
C
B
['A']Q15output1 mark
What is the output?
stack = [2, 4, 6, 8]
while stack:
print(stack.pop())
Correct output:
8
6
4
2