Computational thinking

Cards (37)

  • Decomposition
    Breaking down into smaller parts. Both problems and solutions can be decomposed into smaller parts
  • Abstraction
    The process of removing or hiding unnecessary details so that you can focus solely on the important points
  • Algorithms provide the precise instructions needed to solve a problem. All computer programs are algorithms
  • Once an algorithm has been written, it can be reused with slight changes for solving similar problems which is much quicker than starting from scratch each time
  • Subprogram
    A self-contained block of code that performs a specific task within a larger program
  • Subprograms
    • They only need to be written once and can be used as many times as needed within a program or saved in a library and used in other programs
  • Pre-existing subprograms
    Ready-made subprograms that perform common tasks, such as handling output to the screen, counting the number of characters in a string and generating random numbers
  • User-defined subprograms

    Subprograms that programmers can write to carry out specific functions within their code
  • Using subprograms
    • Breaks down a complex program into a number of smaller, less complicated parts that are easier to code and debug
    • Makes program logic clearer
    • Makes it easier to maintain code
    • Enables code to be used as many times as needed within a program, thus avoiding unnecessary duplication
    • Enables code used for common tasks to be stored in libraries and reused in other programs
    • Enables a team of programmers to work together on a project at the same time
  • Abstraction allows a programmer to specify what a subprogram must do without worrying about how it will work
  • Generalisation
    Parameter passing (sending values into a subprogram for it to work on) enables a subprogram to carry out the same task for the different input values passed into it
  • Flowcharts are used to display algorithms. They are translated into program code that can be executed on a machine
  • Terminal
    Flowchart symbol that shows the start and end of an algorithm. There should be only one start and one end symbol in each flowchart
  • Sequence
    Flowchart symbol that shows the flow of the program, i.e. the next instruction to be executed
  • Decision/Selection
    Flowchart symbol that shows yes/no or true/false decisions where there are two possible outcomes
  • Input/Output
    Flowchart symbol that shows when data is input into or output by the algorithm
  • Subprogram
    Flowchart symbol that shows a function or procedure that has its own flowchart
  • There are four ways to control the flow of a program: sequence, selection, repetition, and iteration
  • Variable
    A named location in memory that can change while a program is running
  • Constant
    A named location in memory that must not change while the program is running
  • Naming conventions

    Variables are named in camel case, where the first word is lower case. Constants are named in all upper case
  • Assignment
    The association of a piece of data with a variable or constant, e.g. SET index TO 0 or index = 0
  • Array
    A data structure that can store multiple items of data, called elements, which are all of the same data type under the same identifier
  • Two-dimensional array

    An array where there is a second array at each index position of a one-dimensional array, forming a matrix
  • Record
    A collection of data objects, where each data element is called a field and can be a different data type
  • Table
    A collection of records that can be thought of as a two-dimensional data structure
  • AND operator

    Ensures that the overall statement is true only if all of the individual statements are true
  • OR operator

    Ensures that the overall statement is true if any of the individual statements are true
  • NOT operator

    Used to reverse the logical state of the other operators
  • When x = 2, y = 6 and z = 9, the output is "Not met"
  • Using the OR operator
    if ((num1 = 3) or (num2 > 6) or (num3 = 10)): result = True
  • For a result to be true then any one or all of the statements has to be true, e.g. if num1 == 3, then the overall statement is true even if the other numbers are not 6 and 10
  • Using the NOT operator
    if (not ((num1 == 3) or (num2>6))): result = True
  • Without the NOT operator, the statement would be true if either num1 == 3 or num2 == 6. Therefore, with the NOT operator, both must be false for the overall statement to be true
  • Note the use of brackets. The statement inside the brackets is evaluated before the condition outside is applied
  • Operator precedence
    Logical operators are evaluated in a particular order: NOT, AND, OR. The order can be changed with the use of brackets
  • The OR statement in brackets is true as y is equal to 6. But the overall statement is false as z is equal to 9 and it must NOT be equal to 9 for the statement to be true. The output will be 'Not met'