Preview

20 - Testing and Errors

 1. Which of the following statements are True?
1. Syntax errors are harder to find than logic errors
2. Using the wrong boolean operator (e.g. AND / OR ) is a logic error
3. Syntax errors will prevent the code from running
4. Logic errors will prevent the code from running. 

  1 and 4 are true

  All of them are true

  All of them are false

  2 and 3 are true

 2. A little history on bugs ....Fill in the blanks below.
An error in a program is sometimes called a ____
This is because __________________ discovered a moth in a 
computer which was stopping it from functioning correctly.
uploads/gracehopper.jpg

  bug / Grace Hopper

  test / Ada Lovelace

  bug / Ada Lovelace

  mug / Alaness Turingda

 3. What type of error? Fill in the blanks below.
____________ errors are errors which may cause program errors or the 
computer to crash even if there appears to be nothing wrong with 
the program code.
They are only detected once the program is ___________
Examples could be: Running out of memory

  Syntax / closed

  Runtime / executed /

  Syntax / executed

  Logic / closed

 4. Provide examples of Syntax errors.
Syntax errors are mistakes in the way that the code is written. 
Translators can only execute a program if it is syntactically correct. 

Common syntax errors include:
==============================

1. spelling mistakes
2. incorrect use of punctuation
3. use of capital letters
4. Running out of memory
5. Using a + instea of a - to perform a calculation
6. Using an 'and' instead of an 'or' in a boolean expression
7. Opening brackets without closing them
8. Entering several decimal points in one number.

  1,5,6,8

  4,5,6

  None of these are examples of syntax errors

  1,2,3,7,8

 5. __________ errors are considered the most difficult to fix. They occur when the program runs without crashing, but produces an incorrect result. The error is caused by a mistake in the program's ___________

  functional

  syntax

  runtime

  logic

 6. Which of the following are examples of logic errors?
1. using the wrong variable name
2. spelling a command wrong
3. indenting a block to the wrong level
4. division by zero
5. using integer division instead of floating-point division
6. getting operator precedence wrong
7. making a mistake in a boolean expression
8. off-by-one, and other numerical errors 

  1,2,3,4,5

  4,8

  7,8

  1,3,5,6,7,8

 7. Can you spot the error(s)?
number1 = int(input("Enter Number 1:"))
number2 = int(input("Enter Number 2:"))
sum = number 1 + number 2 
print(sum)

  logic and syntax error on both lines 1 and 2

  syntax error on line 3

  no errors - it will run fine

  logic error on line 3

 8. There are two types of testing referred to in the below paragraphs. Fill in the blanks.
___________ testing is testing the code as you create it.  
This could completed line by line or a section at a time.  
Once tested and feedback is received you then alter your code as required.  
You could consider this type of testing similar to tuning a guitar.  
You keep playing the string and adjusting the tension until the note is the 
correct pitch.


______ or Terminal testing is carried out at the end of the program 
when it has been written.  
This is more similar to the GCSEs which are taken at the end of the term.
It is used to check what happens when a range of predefined 
test data is entered or used in the program

  Iterative / Final

  Iterative / Initial

  Final / Interative

  Blackbox / Iterative

 9. When testing programs it is very important to select and use suitable "Test Data". Fill in the blanks below to define the different types of test data.
_____ “ Data that is correct  
______ “ The maximum values of the data that could be entered e.g. age limit = 19
_______ “ Values higher or lower than the expected range
_________ “ when no data is entered or left blank to test what happens.
_________   -  incorrect values such as entering 'Dave' in an age field.
__________    - values that are just on the boundary of the valid and invalid

  Valid / In-range / Out-of-range / Null Value / Invalid / Boundary

  Valid / max-range / In-range / Presence Check / Valid / Boundary

  Tested / Valid / Out-of-range / Invalid / Null Value / Boundary

  In-range / Valid / Out-of-range / Invalid / Null Value / Tested

 10. Testing is often completed in a test plan which sets out the test number, the data entered, the type of test data, the __________________________, the result of the test and action required as a result of the test

  functional program

  expected outcome

  tested data

  tabled format