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

  2 and 3 are true

  All of them are false

  All of them 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.

  bug / Grace Hopper

  bug / Ada Lovelace

  test / 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

  Runtime / executed /

  Syntax / closed

  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.

  None of these are examples of syntax errors




 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 ___________





 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 





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

  no errors - it will run fine

  logic and syntax error on both lines 1 and 2

  logic error on line 3

  syntax 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 / Initial

  Iterative / Final

  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

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

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

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

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

 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

  tabled format

  functional program

  tested data

  expected outcome