Cards (49)

  • Sequence
    Structuring code into a logical, sequential order
  • Selection
    Decision making using if statements
  • Iteration
    Repeating code using for or while loops
  • Variables
    Used to store data in programs, can be changed as the program runs
  • Variable
    Has two parts - the data value and an identifier
  • Efficient program
    • Uses variables with sensible identifiers that immediately state their purpose in the program
  • Local variables
    Declared within a specific subroutine, can only be used within that subroutine
  • Global variables
    Can be used at any point within the whole program
  • Local variable advantages
    • Saves memory, easier to debug, can reuse subroutines in other programs
  • Global variable advantages
    • Variables can be used anywhere in the whole program, makes maintenance easier, can be used for constants
  • Constant
    Data that does not change in value as the program is run, it is fixed and remains the same
  • Comparison operators
    Used to compare two data values
  • Common comparison operators
    • Equal to
    • Not equal to
    • Greater than
    • Less than
    • Greater than or equal to
    • Less than or equal to
  • Arithmetic operators
    Used to mathematically manipulate values
  • Common arithmetic operators
    • Add (+)
    • Subtract (-)
    • Multiply (*)
    • Divide (/)
    • Modulo division (%)
    • Integer division (//)
    • Exponentiation (^)
  • Logical operators

    Typically use TRUE and FALSE values (Boolean)
  • An array is a static data structure that can hold a fixed number of data elements. Each data element must be of the same data type i.e. real, integer, string.
  • Index
    The number that indicates the position of a data element in an array. The first element in an array always has an index of 0.
  • Traversing an array
    Use a for loop to display each data element in order
  • Inserting a value in an array
    Change the value of elements that already exist (cannot insert new values)
  • Deleting a value in an array

    Overwrite the element with a blank space (cannot delete values)
  • Searching an array
    Use a for loop to search through each element for a specific value
  • Two-dimensional array
    An array with multiple rows and columns, where the data must still be of the same data type
  • Printing a specific data element in a two-dimensional array
    Use the index number for the row and column
  • Searching a two-dimensional array
    Use two for loops, one for the rows and one for the values in each row
  • Record
    Can store data of different data types, each record is made up of information about one person or thing, each piece of information is called a field, records should have a key field that uniquely identifies each record
  • SQL (Structured Query Language)
    A language used to search for data in a database, the format is:
    SELECT field1, field2, field3...
    FROM table
    WHERE criteria
  • SQL uses wildcards, which are symbols used to substitute characters. The * symbol represents ALL fields.
  • Programs create and process data, which is stored in files that can be accessed, changed and shared
  • Data types
    • Character
    • String
    • Integer
    • Real
    • Boolean
  • Creating a new file in Python
    1. Open file for writing using the open() function with the "w" parameter
    2. Specify the name of the file (e.g. "users.csv")
  • Character

    A single character, such as a letter, number or punctuation symbol
  • Opening a file in Python
    1. Use an open command to open the file
    2. The variable holds a pointer to the file once it is opened, it's called the file object or file handle
  • String
    A sequence of characters, including letters, numbers and punctuation
  • If you don't specify a flag, the file is opened read-only
  • Reading a file in Python
    1. Open the file
    2. Use the readline() method to read one line at a time from the start of the file
    3. Close the file using the close() command
  • Integer
    A whole number
  • Reading an entire file into a list in Python

    1. Open the file
    2. Use the readlines() method to read the whole file into a list
    3. Close the file using the close() command
  • Real
    A decimal number
  • Boolean
    An answer that only has two possible values