Boolean
A data type that is either true or false
Rule
A rule in programming is a guideline that tells you how code should be written and behave. These rules help make sure your program works properly and is easy to understand.
Syntax rules
Using the correct structure (e.g. brackets, semicolons).
Naming rules
Using clear names for variables (e.g. totalMarks, not x).
Control rules
Deciding how the program runs and can include: sequence, selection and iteration.
Sequence
is a control rule and outlines how steps run in order.
Selection
is a control rule about making decisions (if, else).
Iteration
is a control rule about repeating steps (for, while loops).
Validation rules
Checking if data is correct (e.g. age must be between 0–120).
Error handling rules
What to do if something goes wrong.
Strings
A string is a sequence of characters enclosed in quotes. It can include letters, numbers, symbols, and spaces. For example: name = “Bob”
Integers
An integer is a whole number (no decimal point). For example: age = 30
Floats
A float is a number that has a decimal point. For example: price = 19.99
Lists
A list is an ordered collection of items (which can be of any type), enclosed in square brackets. For example: colors = [“red”, “green”, “blue”]
Dictionaries
A dictionary is a collection of key-value pairs, enclosed in curly braces. For example: person = {“name”: “Bob”, “age”: 30, “city”: “Ballarat”}
Control Structures
These are used to control the flow of a program. Common ones include:
if/elif/else: Conditional logic.
For example:
# if statement
if age > 18:
print(“Adult”)
for and while loops: Repeating actions
For example:
# for loop
for color in colors:
print(color)
Modules
A module is a file containing Python code (functions, variables, classes) that you can import and use in your program. For example: import math
Variables
A variable stores data that can be used and changed throughout a program. For example:
message = “Welcome!”
count = 5
Print Statements
The print() function displays output to the console. print(“Hello, Bob!”)
Function
A pre-made block of code that performs a specific function, e.g: print() and return().
Input
Displays text and collects any responses.
Displays text on the screen.
Syntax error
An error caused by invalid code, which breaks the rules of the programming language.