Cards (88)

  • Arrays in Python can store mixed data types.
    False
  • Arrays in Python have a fixed size once they are created.

    True
  • What is the key difference between lists and arrays regarding their size?
    Dynamic vs. fixed
  • Steps to create and use a list in Python
    1️⃣ Create a list using square brackets
    2️⃣ Add elements to the list
    3️⃣ Access elements by their index
    4️⃣ Modify list elements as needed
  • Lists in Python are immutable, meaning their elements cannot be changed.
    False
  • Lists in Python are mutable, allowing elements to be changed during runtime.

    True
  • Lists require more memory due to dynamic resizing.

    True
  • Arrays in Python can grow in size during runtime.
    False
  • Arrays in Python use less memory
  • Lists in Python can grow using the append
  • Lists in Python use more memory due to resizing.

    True
  • Lists in Python support mixed data types within the same list.
    True
  • Arrays in Python have a fixed size, unlike lists.

    True
  • Match the `type_code` with its corresponding data type:
    'i' ↔️ Integer
    'f' ↔️ Float
    'c' ↔️ Character
  • Arrange the steps for creating an array of integers in Python.
    1️⃣ Import the array module
    2️⃣ Create the array with the 'i' type_code
    3️⃣ Populate the array with integer elements
  • Lists in Python use more memory due to dynamic resizing
  • Arrays in Python use less memory than lists because they do not require dynamic resizing
  • What is a key difference between lists and arrays in terms of memory usage?
    Lists use more memory
  • Arrange the following features of lists and arrays based on flexibility from least to most flexible:
    1️⃣ Arrays have fixed size
    2️⃣ Arrays store homogeneous data
    3️⃣ Lists have dynamic size
    4️⃣ Lists store mixed data
  • What does the `list.append(element)` operation do in Python?
    Adds an element to the end
  • Arrays in Python require the `array` module
  • Arrays in Python have a fixed size, unlike lists.

    True
  • Arrays in Python are more flexible than lists in terms of size and type.
    False
  • Arrays use more memory than lists due to dynamic resizing.
    False
  • Adding elements to lists can be done by appending or inserting at a specific index
  • Match the operation with its corresponding method or syntax:
    Access ↔️ mylist[index]my_{l}ist[index]
    Assign ↔️ mylist[index]=my_{l}ist[index] =newvalue new_{v}alue
    Iterate ↔️ fornummylist:for num \in my_{l}ist:
  • What type of loop is used to iterate through an array in Python?
    forfor
  • How do you remove the first occurrence of a value from a list?
    mylist.remove(value)my_{l}ist.remove(value)
  • Why does dynamic resizing lead to higher memory usage in lists?
    Old data is copied
  • What is the primary purpose of lists and arrays in programming?
    Store multiple values
  • Why do arrays use less memory than lists?
    Fixed size
  • What type of data do arrays typically store?
    Uniform data
  • Lists can store data of different types within the same structure.

    True
  • What is the syntax for creating a list in Python?
    [element1, element2, ..., elementN]
  • What is the syntax for creating a list in Python?
    [element1, element2, ..., elementN]
  • Why do arrays use less memory than lists in Python?
    Fixed size
  • What is the primary advantage of using arrays over lists in terms of operations?
    Faster access
  • What method is used to access an element in an array by its index?
    my_array[index]
  • Arrange the operations of lists and arrays in Python based on their strengths.
    1️⃣ Lists are flexible for adding/removing elements
    2️⃣ Arrays provide faster access to elements
  • Arrays in Python are fixed in size and cannot grow.

    True