8.

Cards (142)

  • Algorithmic thinking
    A way of getting to a solution by identifying the individual steps required by creating a set of rules - an algorithm - that, when followed precisely, will lead to an answer
  • Algorithms are used for doing multiplication in school - if a human or computer follows the rules precisely, the answer can be found
  • Algorithm to perform a word search
    1. Find any instances of the first letter of the word
    2. Check surrounding letters to see if they match the next letter
    3. Proceed logically, checking each row until the full word is found
  • The algorithm uses a logical, methodical approach to find any word in a word search if it exists
  • Simplified pseudo-coded English for the word search algorithm
    1. For every word to find
    2. For every letter in the grid
    3. If the grid letter equals the first letter of the word
    4. Check adjacent letters for the second letter
    5. Check remaining letters in the same direction
    6. If a letter doesn't match, move on
    7. If all letters match, the word is found and output its location
  • Abstraction
    • Allows us to think about what's important and what's not - we need to store the letters, their locations, and a way to refer to each letter, but the size of the grid and the specific words are not important
  • The grid can be represented as a list within a list in Python, with the word stored as a variable
  • Implementing the word search algorithm in Python
    1. Use nested for loops to check every letter in the grid
    2. Check if the first letter of the word matches a letter in the grid
    3. Expand the search to adjacent letters, checking the remaining letters in the same direction
    4. Ensure the search stays within the bounds of the grid
    5. Output the location of the found word
  • Algorithmic thinking takes practice, but the more you do it, the better you will become
  • Integer
    Whole numbers, both positive and negative
  • Real (Float)
    Positive and negative numbers with a fractional component (e.g. -1.25)
  • Char
    Holds a single character
  • String
    Holds a sequence of characters
  • Boolean

    Stores logical values (true or false)
  • Each data type uses a different amount of memory
  • Using the correct data type optimizes programs
  • Beat the Dice program
    1. Roll two dice
    2. Determine order of dice values (highest first)
    3. Output dice values in order
  • Dice1 and Dice2 variables
    Store integer values 1-6 (representing dice rolls)
  • Python doesn't require declaring variable data types before use
  • Python infers data types based on first assignment
  • Concatenating strings vs adding integers produces different results
  • Data casting
    Converting one data type to another
  • Data casting is beyond the IGCSE syllabus
  • Being able to gather inputs from the user via the keyboard and display output to a display screen is a very common feature of computer programs
  • Every language does this slightly differently
  • The video shows how to perform user input and display output in three programming languages: Python, Visual Basic, and C#
  • User input
    1. User presses enter
    2. Input is assigned and stored in a variable
  • Prompt
    A message displayed to the user to request input
  • Output
    1. Display a literal string
    2. Display the contents of a variable
    3. Concatenate a string and a variable
  • Format specification
    A way to control the display of a variable with a long decimal fraction
  • The video also shows how these concepts would look in exam papers following the Cambridge IGCSE pseudocode format
  • Pseudocode format
    • Inputs and outputs are separate lines
    • Concatenation uses commas instead of the plus symbol
  • The three basic programming constructs are sequence, selection, and iteration (looping)
  • Sequence
    Executing instructions in order, one after the other
  • Selection (Branching)

    A program will branch depending on certain conditions
  • Selection (Branching)
    • If dice1 is greater than dice2, do one thing, else do another
    If user input equals role value, do one thing, else do another
  • Match Statement
    Allows one of several different branches of code to be executed depending on the value of a variable
  • Match Statement
    • If user enters 'child', set club price to 5
    If user enters 'adult', set club price to 10
    If user enters 'senior', set club price to 6.5
    If none of the above, use default case
  • Iteration (Looping)

    Repeating sections of code
  • For Loop

    • Used when the required number of iterations is known ahead of time
    Runs the loop a specific number of times