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)

  TRUE

  FALSE

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

  Syntax Errors

  Logic Errors

  Continuous Errors

  Run Time 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 and turn the error into a logic error

  Always run as the compiler will automatically compile the error

  Always run

 4. An example of a syntax error would be:

  Spelling errors with commands

  Spelling errors with variables

  Not closing iteration loops or if statements correctly

  All of the above

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

  Run Time Errors

  Syntax Error

  Logic 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

  Syntax Errors

  Continuous Errors

  Run Time Errors

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

  Logic Error

  Continuous Errors

  Run Time Errors

  Syntax Error

 8. Errors in a mathematical formula are usually

  Continuous Errors

  Syntax Errors

  Run Time Errors

  Logic Errors

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

  Run Time Errors

  Logic Errors

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

  Syntax Error

  Logic Error

  Continuous Errors

  Run Time Errors

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

  TRUE

  FALSE

 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.')

  whille should be while, making this a logic error

  print should be PRINT making this a run time error

  None of the above

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

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

  None of the above

 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

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

  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

  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

  Combine Harvester Error

  Run Time Error