Paper 2 [EQ]

Cards (80)

  • Describe the purpose of a truth table. (2)
    Shows the output for each possible input
  • (i) Define the term casting
    Changing one data type to another
  • Describe the steps a binary search will follow to look for a number in a sorted list. (4)
    Check the middle number and see if its the number you are looking for
    Make sure it is in order
    If number is bigger than what you are looking for disregard right hand side if smaller disregard left hand side
    Repeat until number is found
  • Describe the steps a linear search would follow when searching for a number that is not in the given list. (2)

    Check each value from beginning to end
  • (a) Give two ways that the maintainability of this program could be improved.
    Put into subroutines
    Comments for codes
    Iteration
  • Name the data types
    Nights - Interger
    Room - String
  • Either a compiler or an interpreter can translate the code.
    Describe two differences between how a compiler and an interpreter would translate the code.
    • Interpreter translates source code line by line and is slower than a compiler, also outputs errors line by line
    • Compiler creates an executable file and translates all the code at once
    • How to increase the maintainability of a code
    • Comments in the code
    • Consistent in naming variables (sensible names)
  • What is a logic error?
    • Produces an output but not the expected results
  • What is one method of defensive design
    • Input validation
  • What does Input Validation do
    • Ensures the user meets the specific criteria before proceeding
  • 5 Type of Checks for Input validation
    • Type Check (whether its an interger or stringer inputted)
    • Range Check (Of the data entered in the correct range)
    • Presence check (User might not enter any data)
    • Format check (Data needs to be corrected in the correct format etc dates)
    • Length check (Data must be above a certain length)
  • Does Input validation help the programmer make their program more robust?
    Yes
  • For trace table you go line by line
    Trace Table
  • Question for trace table
    Trace Table
  • High-level language
    • Uses code written in a way that is similar to a human language
    • Easier to understand the language
    • Easy to use the language
  • What must happen to high-level language
    • Must be translated into machine code before it can be run. High level language cannot be executed directly by the CPU
  • Another word for Machine Code
    • Binary
  • Example of High-Level language
    • Python
  • Disadvantage of low-level language
    • Hard for humans to understand and write in
  • What are the two types of low-level languages
    • Machine Code
    • Assembly language
    • Two programming codes in Assembly
    • INP
    • OUT
  • What is faster Machine Code or High Level Language
    • Machine code
  • Interpreters
    • Interpreter translates source code line by line
    • Interpreter slower than a compiler because the code must be interpreted each time program is run
    • Interpreters are smaller and simpler problems
    • Once the interpreter encounter and error, it immediately stops the program from running
  • Compilers
    • Translates all the source code in one go
    • Produces an executable file that will run on other machines
    • Compiled programs run faster, they can produce more efficient codes
    • Tend to be large complex programs
    • Compiler would analyse the entire program
  • Explain why people should be encouraged to use energy efficient electrical devices
    • Less energy wasted
    • Less fossil fuels burned less damage to the environment
  • What is abstraction
    • Ignoring unnecessary information and focusing on the important ones
  • What is decomposition
    • Problem broken down into smaller tasks so that it can be solved
  • Selection
    • if
    • then
    • else
  • Iteration
    • while
    • for
  • Write a program to enter the titles of the 10 most popular films of the previous year and store them in a text file. You need to create and open the file, add the records and then close the file
    filmfile = openWrite("films.txt")
    FOR count = 1 TO 10
    filmTitle = input("Enter film title")
    filmfile.writeLine(filmTitle)
    NEXT count
    filmfile.close()
  • Reading and printing all records in a file
    newfile("Members.txt")
    new = openWrite("Members.txt")
    INPUT members
    while NOT members== "x"
    new.writeLine(members)
    INPUT members
    endwhile
    new.close()
  • word = dinosaurs
    print(word.substring(2,3))   outputs nos
    print(word.left(3))                  outputs din
    print(word.right(4))       
    1. substring = nos
    2. wordleft = din
    3. wordright = aurs
  • Pseucode for lower case
    print(phrase.lower)
  • what is an if statement within an if statement called or a loop within a loop
    • nesting
  • what is called when you extract certain parts of a string (for example using a substring)
    • slicing
  • Trace Tables (can leave gaps)
    Trace table
  • Local variable
    • Declared within a specific subroutine
    • Can only be used within that subroutine
  • Local Variable advantages
    • Saves memory (only needed when the local memory is used)
    • You can reuse subroutines with local variables
    • Easier to debug local variables can be changed within one subroutines
  • What is a Global Variable
    • Variable that can be used within any point in the program