Preview

07 - Syntax, Runtime, Logic Errors

 1. One of the main differences between logic and syntax errors is that logic errors occur more frequently and involve errors in the language (e.g. spelling a command wrong)

  FALSE

  TRUE

 2. _____________ are errors that occur when instructions do not follow the rules or the grammar of the programming language

  Syntax Errors

  Logic Errors

  Run Time Errors

  Continuous Errors

 3. When you have a syntax error and try to run the program, the program will

  Always run and turn the error into a logic error

  usually not execute because the syntax error will preven the program from running

  Always run as the compiler will automatically compile the error

  Always run

 4. An example of a syntax error would be:

  Not closing iteration loops or if statements correctly

  Spelling errors with variables

  All of the above

  Spelling errors with commands

 5. Not putting double quotes around text so that the program assumes the text is a variable would be an example of a:

  Syntax Error

  Run Time Errors

  Continuous Errors

  Logic Error

 6. _________________do not stop a program running or produce error messages but will result in a program not running in the way it was expected to

  Continuous Errors

  Logic Errors

  Run Time Errors

  Syntax Errors

 7. PRiNTX("Hello World") instead of the correct command print("Hello World") would be an example of a:

  Run Time Errors

  Syntax Error

  Logic Error

  Continuous Errors

 8. Errors in a mathematical formula are usually

  Run Time Errors

  Syntax Errors

  Logic Errors

  Continuous Errors

 9. Sequential instructions in the wrong order do not stop the program from running but produce the wrong result and are examples of:

  Logic Errors

  Run Time Errors

  Syntax Errors

  Continuous Errors

 10. Referring to variables that have not been set correctly. i.e. count = count + step when step has not previously been assigned a value is a …

  Syntax Error

  Continuous Errors

  Logic Error

  Run Time Errors

 11. Syntax errors are usually the hardest to spot - much harder to spot than logic errors.

  FALSE

  TRUE

 12. Can you spot the error?
x = int(input('Enter a number: '))

whille x%2 == 0:
    print('You have entered an even number.')
else:
    print ('You have entered an odd number.')

  print should be PRINT making this a run time error

  whille should be while, making this a syntax error

  None of the above

  whille should be while, making this a logic error

 13. Can you spot the error in this code?
x = float(input('Enter a number: '))
y = float(input('Enter a number: '))

z = x+y/2
print ('The average of the two numbers you have entered is:',z)

  None of the above

  A logical error because of the order of operations in arithmetic (the division is evaluated before addition) so the program will not give the right answer

  A syntax error because of the order of operations in the arithmetic will produce the wrong output

  A run-time error because z = x+y/2 will crash the program as division by x is not possible

 14. Why is the following vb.net code going to produce a logic error?
Dim x As Integer
Dim y As Integer
Dim answer As Integer

x = 10.5
y = 3
answer = x * y
TextBox1.Text = answer

  x is a reserved 'word' and cannot be used for the creation of a variable

  A floating point number has been put into an integer variable type

  It will produce no error whatsoever

  It will not produce a logic error - it will produce a syntax error

 15. When a program that has an error stills executes (runs) but just gives you an answer that you do not expect, this is likely to be a….

  Run Time Error

  Syntax Error

  Logic Error

  Combine Harvester Error