Cards (32)

  • What is an algorithm?
    A set of rules/instructions to complete a task.
  • How does Abstraction relate to Programming?
    Abstraction helps program by hiding technical details, simplifying complex problems, and focusing on essential features.
  • Three basic control structures used in programming
    • Sequence
    • Selection
    • Iteration
  • Three operators used in Boolean expressions
    • AND
    • OR
    • NOT
  • Selection
    An IF statement is a selection statement. The next statement to be executed depends on whether the condition being tested is True or False.
  • Comparison expressions
    The condition average >= 80 is a Boolean expression. The outcome will always evaluate to TRUE or FALSE.
  • Comparison operators

    • ==
    • !=
    • >=
    • <=
  • = is not used to mean equal to, as a single = is used for assignment
  • If statements
    If statements allow different branches to be executed based on the result of a Boolean expression.
  • Complex Boolean expressions
    Boolean expressions can include the Boolean operators AND, OR and NOT
  • Switch/case statement
    This statement may be used when a selection is to be made from several alternatives, for example when choosing from a menu.
  • Arithmetic operators
    • +
    • -
    • *
    • /
    • ^
    • MOD
    • DIV
  • Variables
    Containers that store data values
  • Data types of variables

    • Integer
    • Boolean
    • Real / Floating point number
    • Character
    • String
  • Constants
    Values that cannot be changed during program execution
  • Constants are typically shown in uppercase with words separated by an underscore
  • Why declare a constant instead of a variable?
    • Prevents the value from being changed accidentally
    • Shows the programmer the value should stay the same
  • A constant cannot be changed when the program is running, but can be changed by a programmer before the program is compiled or translated
  • Input and output statements
    1. Accept data from the user
    2. Process the data
    3. Output the result
  • INPUT statement
    Displays a prompt for the user and waits for their response, which is then assigned to a variable
  • DIV
    Integer division, also known as quotient
  • MOD
    Remainder when dividing one integer by another
  • BIDMAS
    Order of precedence: Brackets, Indices, Division, Multiplication, Addition, Subtraction
  • Strings and integers are represented differently in binary
  • Conversions and casting
    Functions used to convert data types (int(), float(), str(), bool(), ASC(), CHR())
  • Inputs from the user are strings, so they need to be converted before use in calculations
  • Concatenating strings
    Joining strings together using the + operator
  • String handling functions
    • length
    • substring
    • left
    • right
  • ASC() and CHR()
    Convert characters to/from their ASCII values
  • Uppercase and lowercase
    Converting strings to all uppercase or all lowercase using .upper() and .lower()
  • Comments are used to describe the purpose, author, and explain the code
  • Comments are ignored when the program is translated to machine code and executed