programming concepts

Cards (31)

  • a variable is a location in memory which stores a value that can be changed
  • a constant is a location in memory which stores a value that does not change
  • reasons for using a constant:
    • only have to change the value once in the source code
    • makes sure the program is consistent as only have to enter the value once
    • makes code more readable
  • sequence
    the idea of one step being done after another in a particular order
  • iteration
    repeating sections of code in a loop (for, while, repeat)
  • selection
    changing the direction of a program based on a specific criteria (if, elif, else)
  • if you don't know how many times a loop will repeat, you use an indefinite loop / condition-controlled loop
  • two types of indefinite loops
    • pre-controlled loops
    • post-controlled loops
  • pre-controlled loops
    the condition is checked before the loop starts and will keep going whilst the condition is true
  • post-controlled loops
    the condition is checked once the loop has finished and will stop as soon as the condition is true
  • if you do know how many times the loop will repeat, you use a definite loop / counter-controlled loop
  • nested loops
    putting loops inside each other
  • nested if statements
    if statements within each other
  • relational operators
    being able to compare two values and return either true or false
  • <
    less than
  • >
    greater than
  • =
    equals
  • !=
    not equal
  • <=
    less than or equal to
  • >=
    greater than or equal to
  • arithmetic operators
    mathematical calculations within in a program
  • +
    addition
  • -
    subtraction
  • *
    multiplication
  • /
    division
  • MOD
    finds the remainder when the first number is being divided by the second
  • DIV
    finds the whole part when the first number is being divided by the second
  • boolean operators
    being able to compare one or two boolean values and return either true or false
  • not
    reverses the input (not true = false)
  • and
    checks if both inputs are true and returns true if so, false otherwise
  • or
    checks if either input is true and returns true if so, false otherwise