MCQz

Computational Structures

Computer Science · 11th Class (Intermediate Part 1) · BISE Lahore

70 questions

Tests for this chapter

Tests run in your chosen medium — the sample below shows both.

Computational Structures Test

10 questions · Computational Structures × 10

Full Book Test

20 questions · Introduction to Software Development × 3, Python Programming × 3, Algorithms and Problem Solving × 2, Computational Structures × 2, Data Analytics × 3, Emerging Technologies × 2, Legal and Ethical Aspects of Computing System × 2, Online Research and Digital Literacy × 1, Entrepreneurship in Digital Age × 2

Sample questions

Showing 20 of 70 questions from this chapter. The full bank is in the chapter test below.

  1. 1

    In Python, which pair of characters encloses the items when a list is created?

    • A.Square brackets [ ] (correct answer)
    • B.Curly braces { }
    • C.Round parentheses ( )
    • D.Angle brackets < >
    Why: A list literal is written with square brackets and comma-separated items, as in items = ['Snacks', 'Plates']. Curly braces build a set or a dictionary, and round parentheses do not create a list.
  2. 2

    Which statement about indexing in a Python list is correct?

    • A.The first element is at index 1 and the last at index 0
    • B.The first element is at index 0 and negative indices count from the end (correct answer)
    • C.Indexes can only be positive whole numbers
    • D.The index of an element is the same as its value
    Why: Python lists are zero-indexed, so the first element sits at index 0 while -1 refers to the last element. The first option swaps the ends, and the idea that indexes must be positive fails because -1 and -2 are valid indexes.
  3. 3

    What is printed by: party_list = ['Buy drinks', 'Buy decorations', 'Buy snacks']; party_list.insert(0, 'Invite friends'); print(party_list)

    • A.['Invite friends', 'Buy drinks', 'Buy decorations', 'Buy snacks'] (correct answer)
    • B.['Buy drinks', 'Invite friends', 'Buy decorations', 'Buy snacks']
    • C.['Buy drinks', 'Buy decorations', 'Buy snacks', 'Invite friends']
    • D.['Invite friends', 'Buy decorations', 'Buy snacks']
    Why: insert(0, 'Invite friends') places the new item at index 0, so it becomes the first element and all the existing items shift one position to the right. Putting the item at the end would be appending, not inserting at position 0.
  4. 4

    In the Python statement party_list.insert(1, 'Buy snacks'), what does the value 1 indicate?

    • A.The value that will be inserted
    • B.The index position where the new item is placed (correct answer)
    • C.The number of copies of the item to insert
    • D.The new length of the list after the insertion
    Why: insert() takes the target index first and the item second, so 1 means the new item goes in at index 1. The item itself is the second argument of the call, not the first.
  5. 5

    Which list method removes the first occurrence of a particular value from the list?

    • A.pop()
    • B.append()
    • C.remove() (correct answer)
    • D.clear()
    Why: remove(value) searches the list and deletes the first element equal to that value. pop() deletes by position instead, and clear() empties the whole list.
  6. 6

    What is printed by: x = ['a', 'b', 'c', 'd']; x.pop(1); print(x)

    • A.['b', 'c', 'd']
    • B.['a', 'c', 'd'] (correct answer)
    • C.['a', 'b', 'd']
    • D.['a', 'b', 'c']
    Why: pop(1) removes the element at index 1, which is 'b', leaving the other three items in their original order. The last option is what pop() with no argument would have produced, since that removes the final element.
  7. 7

    How does remove() differ from pop() when deleting an item from a list?

    • A.remove() deletes by value, while pop() deletes by index and returns the item (correct answer)
    • B.remove() deletes by index, while pop() deletes by value
    • C.remove() only works on the last item, while pop() works on any item
    • D.There is no difference; both take an index
    Why: remove() is given the value to be deleted and returns nothing, while pop() is given a position, removes that element and hands it back to the caller.
  8. 8

    What is printed by: a = [1, 2]; b = a; b.append(3); print(a)

    • A.[1, 2]
    • B.[1, 2, 3, 3]
    • C.An error, because only b was modified
    • D.[1, 2, 3] (correct answer)
    Why: The statement b = a does not copy the list; both names refer to the same list object, so the append done through b is also visible through a. To get an independent copy the program would need something like b = a[:] or b = list(a).
  9. 9

    What is printed by: nums = [3, 5, 7]; print(10 in nums)

    • A.True
    • B.10
    • C.False (correct answer)
    • D.None
    Why: The in keyword tests membership and returns False because 10 is not one of the list elements. It does not return the value being searched for, so 10 itself is not printed.
  10. 10

    What does it mean that a Python list has a dynamic size?

    • A.Items can be added or removed while the program runs and the list adjusts its size (correct answer)
    • B.The list can store only numeric values
    • C.The list keeps its items sorted automatically
    • D.All items in the list must have the same data type
    Why: Dynamic size means the list grows and shrinks as needed at run time, so no maximum length has to be fixed in advance. Automatic sorting and a single data type are not properties of a Python list.
  11. 11

    Which property of a list guarantees that the first item added stays in its position until the list is changed?

    • A.Dynamic size
    • B.Index-based access
    • C.Ordered collection (correct answer)
    • D.Automatic sorting
    Why: The ordered-collection property preserves the order in which items were added, so an item keeps its place until the list is modified. A list is never sorted on its own.
  12. 12

    Which statement adds 9 to the end of the list, so that nums = [1, 5, 7] becomes [1, 5, 7, 9]?

    • A.nums.insert(0, 9)
    • B.nums.append(9) (correct answer)
    • C.nums.pop(9)
    • D.nums.remove(9)
    Why: append(9) adds the new item after the last existing element, so the list grows by one at the end. insert(0, 9) would put the 9 at the front instead, giving [9, 1, 5, 7].
  13. 13

    In a stack, where do both insertion and deletion take place?

    • A.At the bottom only
    • B.At both ends
    • C.Anywhere in the middle
    • D.At the top only (correct answer)
    Why: A stack restricts both insertion and deletion to one end, called the top, and this single-ended access is what produces last-in, first-out behaviour. Allowing work at both ends would no longer be a stack.
  14. 14

    Which computational structure follows the Last-In, First-Out principle?

    • A.Queue
    • B.Graph
    • C.Stack (correct answer)
    • D.Tree
    Why: In a stack the most recently added element is the first one removed, which is the LIFO principle. A queue does the opposite and serves the element that has waited longest first.
  15. 15

    What is printed by: stack = []; stack.append('Book A'); stack.append('Book B'); print(stack.pop())

    • A.Book B (correct answer)
    • B.Book A
    • C.None
    • D.['Book A', 'Book B']
    Why: append() pushes onto the top, so after the two pushes 'Book B' is on top and pop() returns and removes it. 'Book A' would be returned by a stack that behaved like a queue, and the whole list would only be printed by print(stack).
  16. 16

    What happens if a pop operation is performed on an empty stack?

    • A.It causes an error, called a stack underflow, because there is no element to remove (correct answer)
    • B.It returns 0
    • C.It silently adds a new element in its place
    • D.It reverses the order of the whole stack
    Why: With no element on the stack there is nothing to remove, so the pop fails with an error known as underflow; in Python it raises an IndexError. It cannot return 0, because 0 is an ordinary data value that was never stored.
  17. 17

    Which operation returns the element at the top of a stack without removing it?

    • A.push()
    • B.pop()
    • C.enqueue()
    • D.peek() (correct answer)
    Why: peek(), also called top(), reads the element at the top of the stack and leaves the stack unchanged, unlike pop(), which removes it. enqueue() belongs to a queue, not a stack.
  18. 18

    Which operation adds a new element to the top of a stack?

    • A.Pop
    • B.Dequeue
    • C.Push (correct answer)
    • D.Peek
    Why: Push places a new element on top of the stack. Dequeue belongs to a queue, and peek only inspects the top element without adding anything.
  19. 19

    Why is a pile of books a good physical model of a stack?

    • A.Only the top book can be taken off and new books can only be placed on top (correct answer)
    • B.Books can be pulled out from either end of the pile
    • C.The first book placed on the table is always the first one removed
    • D.The pile always stays arranged by size
    Why: The pile mirrors the one-ended access rule of a stack, which gives last-in, first-out order. Pulling a book out of the middle is exactly what a stack does not allow.
  20. 20

    The undo feature of a text editor is commonly implemented with which structure?

    • A.Queue
    • B.Stack (correct answer)
    • C.Graph
    • D.Tree
    Why: The most recent action is the first one undone, which is last-in, first-out behaviour and therefore a stack. A queue would undo the oldest action first, which is not how undo works.
← All chapters of Computer Science