2.2.3 Additional Programming Techniques

Cards (26)

  • What is an array in programming?
    An array is a static data structure that can hold a fixed number of data elements.
  • What must each data element in an array be?
    Each data element must be of the same data type.
  • How are elements in an array identified?
    The elements in an array are identified by an index number.
  • What is the index of the first element in an array?
    The first element in an array always has an index of 0.
  • What is the purpose of pseudo code in relation to arrays?
    Pseudo code is used to manipulate arrays to traverse, add, remove, and search data.
  • How can you traverse an array in Python?
    You can use a for loop to display each data element in order.
  • Can you insert new values into an array?
    No, you cannot insert new values into an array since its size is fixed.
  • What happens when you overwrite the fourth element in an array?
    Overwriting the fourth element changes its value to the new value provided.
  • How can you delete a value in an array?
    You can overwrite it with a blank space to make it appear deleted.
  • How do you search for a specific value in a large array?
    A for loop is needed to search through each element for a specific value.
  • What is a two-dimensional array?
    A two-dimensional array is a data structure that can have multiple rows and columns.
  • How is indexing done in a two-dimensional array?
    Indexing in a two-dimensional array uses two values: row and column.
  • How do you print a specific data element in a two-dimensional array?
    You can use the index number to access and print the specific data element.
  • How do you search for a specific value in a two-dimensional array?
    You need two for loops: one for the row and another for the values of each row.
  • What is a record in programming?
    A record can store data of different data types.
  • What is a field in a record?
    A field is each piece of information in the record.
  • What is a key field in a record?
    A key field is unique data that identifies each record.
  • Why is a Student ID a good key field for a student record?
    Because no two students can have the same Student ID.
  • What does SQL stand for?
    SQL stands for Structured Query Language.
  • What is the purpose of SQL?
    SQL is used to search for data in a database.
  • What is the format of an SQL statement?
    The format is: SELECT field1, field2, field3… FROM table WHERE criteria.
  • Write an SQL statement to display the make and colour for cars that are grey or blue.
    SELECT Make, Colour FROM Cars WHERE Colour = 'grey' OR Colour = 'blue'.
  • Write an SQL statement to display all fields for cars that are 10 years old or less.
    SELECT * FROM Cars WHERE Age <= 10.
  • What are the differences between a 1D array, 2D array, and record?
    • 1D Array: Holds a fixed number of elements of the same data type.
    • 2D Array: Holds multiple rows and columns of the same data type.
    • Record: Can store different data types and consists of fields with a unique key field.
  • What are the steps to manipulate arrays in Python?
    1. Traverse: Use a for loop to display elements.
    2. Insert: Change existing values (cannot add new).
    3. Delete: Overwrite with a blank space.
    4. Search: Use a for loop to find specific values.
  • What is the role of wildcards in SQL?
    • Wildcards are symbols used to substitute characters.
    • The * symbol represents ALL fields.