WeLearn

Grade 12 Information Technology · Unit 6

Fundamentals of Programming

Unit 6 of the Grade 12 Information Technology textbook has 4 lessons: Program Flow Controls and Syntax in Python, Comments in Python, The Python Interpreter and Testing and Debugging Programs.

Lesson 6.2

Comments in Python

Comments are notes written in the source code for humans to read; the Python interpreter ignores them. They explain what the code does, why a decision was made, or what still needs to be done.

CommentSingle-line commentInline commentDocstringCommenting outReadability

Lesson 6.3

The Python Interpreter

Computers execute machine code, so programs written in high-level languages must be translated. A compiler translates the whole program into machine code before it runs (as in C), producing an executable file.

InterpreterCompilerBytecodeInteractive mode (REPL)Script modeIDETraceback

Lesson 6.4

Testing and Debugging Programs

Testing checks whether a program works correctly; debugging is finding and fixing the errors (bugs) that testing reveals. Programs can contain three kinds of errors.

BugDebuggingSyntax errorRuntime errorLogic errorBoundary dataBreakpointException handling

Practice questions

3 of the 6 questions in the Unit 6 quiz. Try each one, then reveal the answer.

  1. 1. In Python, which operator checks whether two values are equal?

    • A. =
    • B. ==
    • C. !=
    • D. :=
    Show answer

    Answer: ==

    == compares values and gives True or False; a single = assigns a value to a variable.

  2. 2. Which symbol starts a single-line comment in Python?

    • A. //
    • B. #
    • C. /*
    • D. --
    Show answer

    Answer: #

    Python ignores everything after # on a line. // is floor division in Python, and /* and -- are comment markers in other languages.

  3. 3. A program runs without crashing but calculates the wrong average. This is a...

    • A. syntax error
    • B. runtime error
    • C. logic error
    • D. compiler error
    Show answer

    Answer: logic error

    Logic errors let the program run but give wrong results, such as forgetting brackets so only one value is divided.

Teach Information Technology Unit 6 with WeLearn

We will bring a demo to your school: a lesson on your interactive TV, a virtual lab and a classroom game, with your own teachers.