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

  Run Time Errors

  Syntax Errors

  Logic Errors

  Continuous Errors

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

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

  Always run

  Always run and turn the error into a logic error

  Always run as the compiler will automatically compile the error

 4. An example of a syntax error would be:

  Spelling errors with commands

  All of the above

  Spelling errors with variables

  Not closing iteration loops or if statements correctly

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

  Logic Error

  Run Time Errors

  Syntax Error

  Continuous Errors

 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

  Logic Errors

  Continuous Errors

  Run Time Errors

  Syntax Errors

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

  Continuous Errors

  Logic Error

  Syntax Error

  Run Time Errors

 8. Errors in a mathematical formula are usually

  Continuous Errors

  Run Time Errors

  Logic Errors

  Syntax 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

  Continuous Errors

  Run Time Errors

  Syntax 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 …

  Continuous Errors

  Syntax Error

  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

  None of the above

  whille should be while, making this a logic error

  whille should be while, making this a syntax 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)

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

  None of the above

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

  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

 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

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

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

  It will produce no error whatsoever

 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….

  Logic Error

  Syntax Error

  Run Time Error

  Combine Harvester Error