Cards (50)

  • An array is an ordered collection of elements of the same data type
  • The size of an array is fixed when it is created
  • To declare an array, you must specify its size and data type
  • To access an array element by index, you use its numerical position
  • Steps to declare and initialize an array
    1️⃣ Declare the array with size and data type
    2️⃣ Initialize the array with values
  • In the array `numbers = [1, 2, 3, 4, 5]`, `numbers[0]` would return the value 1
  • To access elements from index 1 to 3 in the array `numbers = [1, 2, 3, 4, 5]`, you would use the range 1:4
  • Why are arrays useful for programming tasks?
    Fixed size and ordered nature
  • When declaring an array, you must specify its size and data type
  • Match the step with its description:
    Declare ↔️ Define the array with its size and data type
    Initialize ↔️ Assign initial values to array elements
  • When initializing an array with specific values, you assign them to the array's elements
  • Using `numbers[-1]` in an array returns the last element.
  • All elements in an array must be of the same data type
  • The size of an array is fixed when it is created
  • What are common uses of arrays in programming?
    Storing and manipulating data
  • Match the array declaration step with its description:
    Declare ↔️ Define the array with its size and data type
    Initialize ↔️ Assign initial values to the array elements
  • What is zero-based indexing in arrays?
    The first element is at index 0
  • How do you access a range of elements in an array using Python?
    `array[start:end]`
  • What is direct assignment used for in arrays?
    Modifying specific elements
  • What does the capacity of an array refer to?
    The total number of elements it can hold
  • What does the direct assignment operation do in an array?
    Replaces a value at an index
  • The size of an array can be changed after it is created.
    False
  • The size and capacity of an array are both fixed and cannot be modified
  • What is the first step in deleting an element from an array?
    Identify the element to delete
  • Arrays are used to store and manipulate collections of related data
  • Arrays offer fast element access due to their sequential memory allocation.

    True
  • Elements in an array are stored in a specific order and can be accessed by their index.

    True
  • All elements in an array must be of the same data type.

    True
  • Arrays in programming use zero-based indexing.

    True
  • Negative indexing in arrays allows you to access elements from the end of the array.

    True
  • Match the array access method with its description:
    By Index ↔️ Access an element using its position
    Negative Index ↔️ Access from the end of the array
    Range ↔️ Access multiple elements
  • Using `numbers[-1]` in the array `numbers = [1, 2, 3, 4, 5]` would return the last element, which is 5.

    True
  • Arrays in Python use zero-based indexing.

    True
  • Steps to declare and initialize an array
    1️⃣ Declare the array by specifying its size and data type
    2️⃣ Initialize the array by assigning values to its elements
  • Creating an array with `[0] * 5` initializes it with five integer elements, all set to 0.

    True
  • Arrays in Python use negative indexing to access elements from the end of the array.
    True
  • How do you modify an element in an array?
    Direct assignment using index
  • What is an array in computer science?
    An ordered collection of elements
  • All elements in an array must be of the same data type.

    True
  • Arrays allow elements to be accessed by their index