Lesson 6.1
Program Flow Controls and Syntax in Python
Python is a popular, beginner-friendly programming language with clear syntax. Syntax means the rules for writing valid code.
Grade 12 Information Technology · Unit 6
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.1
Python is a popular, beginner-friendly programming language with clear syntax. Syntax means the rules for writing valid code.
Lesson 6.2
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.
Lesson 6.3
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.
Lesson 6.4
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.
3 of the 6 questions in the Unit 6 quiz. Try each one, then reveal the answer.
1. In Python, which operator checks whether two values are equal?
Answer: ==
== compares values and gives True or False; a single = assigns a value to a variable.
2. Which symbol starts a single-line comment in Python?
Answer: #
Python ignores everything after # on a line. // is floor division in Python, and /* and -- are comment markers in other languages.
3. A program runs without crashing but calculates the wrong average. This is a...
Answer: logic error
Logic errors let the program run but give wrong results, such as forgetting brackets so only one value is divided.
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.