Diagnostic Misconceptions - Last Line of Code

Computer Science: OCR GCSE, topic 2.2.22

Code tracing

Programming, especially in Python is procedural. This means that the latest line of code that has been read is the one that applies.

Test yourself on Diagnostic Misconceptions - Last Line of Code

  • What is the final value of the variable ‘a’ in the following code?


    a = 2
    b = 3
    c = 4
    a = b + c
    print(a)

  • What is the final value of the variable ‘a’ in the following code?


    a = 8
    b = 2
    c = 9
    a = b + c
    print(a)

  • What is the final value of the variable ‘a’ in the following code?

  • What is the final value of the variable ‘a’ in the code shown?

  • What is the final value of the variable ‘a’ in the code shown?

Practise this topic for free