Software Engineering › Flashcards › Code Patterns: Pseudocode, Python, SQL, CSS (Years 11 and 12)
Code Patterns: Pseudocode, Python, SQL, CSS (Years 11 and 12)
34 flashcards (Year 11 and 12). Study these as flip cards Random
HSC pseudocode
Pseudocode keywords Code pattern
Keywords are in capitals; structural elements come in pairs (BEGIN/END, IF/ENDIF, WHILE/ENDWHILE); indent to show control structures.
Example: 'IF mark >= 50 THEN ... ENDIF'
- Pseudocode: Write pseudocode (2025 Q17)
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Fill in the blanks: Fill in the blanks or dropdown: choose this term to complete a statement or table.
Related past questions: 2025 HSC Q17 (3 marks): Algorithm design; Sample exam Q7 (1 mark): Python to pseudocode; Sample exam Q14 (3 marks): Algorithm design (subroutines); Familiarisation Q8 (3 marks): Algorithm design (linear search)
Memorise: Python and SQL you must be able to write
Sequence Code pattern
Steps executed one after another in the order written.
Example: 'GET a; GET b; total = a + b'
- Pseudocode: Pseudocode question: use it correctly in the exam pseudocode editor.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Drawing: Drawing question: draw or label it in the online drawing tool.
Related past questions: 2025 HSC Q17 (3 marks): Algorithm design
Memorise: Python and SQL you must be able to write
Binary selection (IF THEN ELSE) Code pattern
IF condition THEN process ELSE other process ENDIF: one of two paths is taken.
Example: 'IF age >= 18 THEN DISPLAY "Adult" ELSE DISPLAY "Minor" ENDIF'
- Pseudocode: Pseudocode question: use it correctly in the exam pseudocode editor.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Drawing: Drawing question: draw or label it in the online drawing tool.
Related past questions: 2025 HSC Q17 (3 marks): Algorithm design
Memorise: Python and SQL you must be able to write
Multi-way selection (CASEWHERE) Code pattern
CASEWHERE expression evaluates to choice a: ... OTHERWISE: default END CASE; only one process runs.
Example: 'CASEWHERE grade evaluates to "A": ... OTHERWISE: ...'
- Pseudocode: Pseudocode question: use it correctly in the exam pseudocode editor.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Drawing: Drawing question: draw or label it in the online drawing tool.
Memorise: Python and SQL you must be able to write
Nested IF Code pattern
An IF inside the ELSE of another IF to test several conditions where only one process runs.
Example: 'IF a THEN ... ELSE IF b THEN ... ELSE ... ENDIF ENDIF'
- Pseudocode: Pseudocode question: use it correctly in the exam pseudocode editor.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Python: Python question: write or complete it in the online Python tool.
Related past questions: 2025 HSC Q17 (3 marks): Algorithm design
Memorise: Python and SQL you must be able to write
WHILE loop (pre-test) Code pattern
WHILE condition is true ... ENDWHILE: the condition is tested before each loop, so the body may never run.
Example: 'WHILE count < 5 ... ENDWHILE'
- Pseudocode: Pseudocode question: use it correctly in the exam pseudocode editor.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Python: Python while
Related past questions: 2025 HSC Q17 (3 marks): Algorithm design; Sample exam Q9 (2 marks): Algorithm design (guessing game)
Memorise: Python and SQL you must be able to write
REPEAT UNTIL loop (post-test) Code pattern
REPEAT ... UNTIL condition is true: the body runs at least once, then the condition is tested.
Example: 'REPEAT GET guess UNTIL guess = answer'
- Pseudocode: Pseudocode question: use it correctly in the exam pseudocode editor.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: Sample exam Q9 (2 marks): Algorithm design (guessing game)
Memorise: Python and SQL you must be able to write
FOR / NEXT loop (counted) Code pattern
FOR variable = start TO finish STEP increment ... NEXT variable; used when the number of repeats is known.
Example: 'FOR i = 1 TO 5 ... NEXT i'
- Pseudocode: Pseudocode question: use it correctly in the exam pseudocode editor.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Python: Python question: write or complete it in the online Python tool.
Related past questions: 2025 HSC Q17 (3 marks): Algorithm design
Memorise: Python and SQL you must be able to write
Check this one: Not found word-for-word in the supplied syllabus, specifications, marking guidelines or notes; the definition is standard computing knowledge, so check it against your class notes.
Subroutine and function (pseudocode) Code pattern
BEGIN name (parameters) ... END name. A function returns a single value with RETURN.
Example: 'BEGIN Add (x, y) total = x + y RETURN total END Add'
- Pseudocode: Pseudocode question: use it correctly in the exam pseudocode editor.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Python: Python question: write or complete it in the online Python tool.
Related past questions: Sample exam Q14 (3 marks): Algorithm design (subroutines)
Memorise: Python and SQL you must be able to write
Array sum pattern Code pattern
Set total to 0, loop through every item adding it to the total, then display the total (initialise, loop, accumulate, output).
Example: 'total = 0; FOR each item: total = total + item'
- Pseudocode: Write algorithm (2025 Q17)
- Python: Python question: write or complete it in the online Python tool.
Related past questions: 2025 HSC Q17 (3 marks): Algorithm design
Memorise: Python and SQL you must be able to write
Check this one: A coding pattern from the exam solution style, not a syllabus term.
Linear search pattern Code pattern
Check each item in order until found or the end is reached; set a Found flag, loop through and stop on a match.
Example: 'found = False; for i in list: if i == target: found = True'
- Pseudocode: Linear search (familiarisation Q8)
- Python: Python question: write or complete it in the online Python tool.
Related past questions: Familiarisation Q8 (3 marks): Algorithm design (linear search)
Memorise: Python and SQL you must be able to write
Python
Python input and output Code pattern
input() reads text from the user as a string; print() displays output; convert with int() or float().
Example: 'age = int(input("Age: "))'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q19 (3 marks): Developing secure code (Python); Sample exam Q18b (3 marks): Developing secure code (Python input validation)
Python selection (if elif else) Code pattern
if condition: ... elif condition: ... else: ...; indentation matters (Q19 marker note: indentation).
Example: 'if mark >= 50: print("Pass") else: print("Fail")'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q19 (3 marks): Developing secure code (Python)
Python for loop and range Code pattern
for i in range(start, stop): repeats; stop is exclusive; also loops over lists and strings.
Example: 'for i in range(1, 6): print(i)'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q26 (5 marks): Design, construct and implement a solution (Python)
Python while loop Code pattern
while condition: ... repeats while True; make sure the condition changes.
Example: 'while guess != answer: guess = int(input())'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: Sample exam Q9 (2 marks): Algorithm design (guessing game)
Python strings and slicing Code pattern
Strings are sequences: len(s), s[0], s[-1], s[1:4], s.upper(), s.lower(), s.split(), s.strip(), and ord()/chr() for character codes.
Example: 'word[0] is the first letter; word[-1] is the last.'
- Python: String processing (2025 Q19)
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q19 (3 marks): Developing secure code (Python)
Python lists Code pattern
A list stores ordered items: append(), remove(), len(), sorting with sort(), looping, and 2D lists as a list of lists.
Example: 'grid = [[0]*3 for _ in range(3)]'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q26 (5 marks): Design, construct and implement a solution (Python); Familiarisation Q13 (6 marks): Python: lists, loops, selection; Sample exam Q21b (5 marks): Python: subroutines, lists, loops
Python 2D list (grid) Code pattern
A list of lists addressed as grid[row][column]; loop with nested for loops.
Example: 'grid[1][2] = 5'
- Python: Grid (2025 Q26, sample Q21)
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q26 (5 marks): Design, construct and implement a solution (Python); Sample exam Q21a (1 mark): 2D arrays (Python); Sample exam Q21b (5 marks): Python: subroutines, lists, loops
Python random numbers Code pattern
import random then random.randint(a, b) gives a whole number a to b inclusive; use a set or a check to avoid repeats.
Example: 'n = random.randint(1, 50)'
- Python: 2025 Q26 random grid
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q26 (5 marks): Design, construct and implement a solution (Python)
Check this one: Library use is allowed under 'modules and libraries'; random.randint is a standard Python function.
Python functions Code pattern
def name(parameters): ... return value. Functions must be defined before they are called (2025 Q19 marker note: call functions after definition).
Example: 'def area(w, h): return w * h'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q19 (3 marks): Developing secure code (Python)
Global and local variables Code pattern
A local variable exists only inside its function; a global variable is declared outside and can be used throughout (use the global keyword to change it inside a function).
Example: 'count = 0 (global); def add(): global count'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Multiple choice: Multiple choice: pick the option that matches the definition or example.
Python file handling Code pattern
open(filename, mode) with modes r (read), w (write, overwrites), a (append); use with to close the file automatically; read(), readline(), write().
Example: 'with open("data.txt") as f: lines = f.readlines()'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Python modules and libraries Code pattern
import a module to use its functions: import random, import math, from sklearn.linear_model import LinearRegression.
Example: 'import math'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Python classes and objects Code pattern
class Name: with __init__(self, ...) to set attributes; methods have self; create objects with Name(...); inheritance with class Child(Parent):.
Example: 'class Dog(Animal): def speak(self): return "Woof"'
- Python: Write a class
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q22 (3 marks): Modelling tools
Python validation function pattern Code pattern
Loop until the input is valid, using try/except for the conversion and if for range checks.
Example: 'while True: try: n = int(input()) ... except ValueError: ...'
- Python: Input validation (sample Q18b, fam Q9b)
Related past questions: Sample exam Q18b (3 marks): Developing secure code (Python input validation); Familiarisation Q9b (3 marks): Developing secure code (Python input validation)
Python try / except Code pattern
try: risky code except ValueError: handle the error; keeps the program running with a helpful message.
Example: 'except ValueError: print("Numbers only")'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: Sample exam Q18b (3 marks): Developing secure code (Python input validation)
Python sqlite3 parameterised query Code pattern
Use ? placeholders and pass values separately, never join user text into the SQL string, to stop SQL injection.
Example: 'cur.execute("SELECT * FROM user WHERE name = ?", (name,))'
- Python: Python question: write or complete it in the online Python tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Short answer: Short answer (2 to 4 marks): define, outline or explain it and tie it to the scenario.
Check this one: Parameterised queries are standard secure practice (defensive input handling); the syllabus does not name sqlite3.
Python file and ML code reading (scikit-learn) Code pattern
Know how to read: import, create the model, fit (train), predict.
Example: 'model.fit(x, y); model.predict([[4]])'
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Python: Python question: write or complete it in the online Python tool.
SQL and CSS syntax
SQL statement structure Code pattern
SELECT fields FROM table WHERE criteria GROUP BY field ORDER BY field ASC or DESC; keyword AS renames a field for display.
Example: 'SELECT Name FROM Games WHERE Cost > 20 ORDER BY Name ASC'
- SQL: Write a query (2025 Q21)
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Multi-select: Familiarisation Q2
Related past questions: 2025 HSC Q21 (4 marks): SQL queries; Sample exam Q17 (3 marks): SQL (join, filter, order); Familiarisation Q12a (2 marks): SQL; Familiarisation Q12b (3 marks): SQL (joins, AS)
Memorise: SQL: HSC syntax and must-know queries
SQL relational and logical operators Code pattern
Relational operators: CONTAINS, DOES NOT CONTAIN, EQUALS, NOT EQUAL TO, GREATER THAN (OR EQUAL TO), LESS THAN (OR EQUAL TO). Logical operators: AND, OR, NOT. Put text and dates in quotes.
Example: "WHERE Name CONTAINS 'war' AND Cost < 50"
- SQL: SQL question: write or read it in the SQL query tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q21 (4 marks): SQL queries
Memorise: SQL: HSC syntax and must-know queries
SQL calculated aggregate with GROUP BY Code pattern
SELECT Developer, SUM(Cost) AS Totalcost FROM Games GROUP BY Developer ORDER BY Developer DESC.
Example: 'SUM (Games.cost) AS Totalcost'
- SQL: SQL question: write or read it in the SQL query tool.
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
Related past questions: 2025 HSC Q21 (4 marks): SQL queries; Sample exam Q22a (2 marks): SQL (GROUP BY)
Memorise: SQL: HSC syntax and must-know queries
CSS rule syntax Code pattern
selector { property: value; } with comments in /* */. h1 targets an element, #welcome targets an id, .red-text targets a class.
Example: '.red-text { color: red; }'
- Code reading: Read CSS (2025 Q7)
- Multiple choice: Multiple choice: pick the option that matches the definition or example.
Related past questions: 2025 HSC Q7 (1 mark): CSS code fragment; Sample exam Q16a (1 mark): CSS (id v class)
Memorise: SQL: HSC syntax and must-know queries
XSS JavaScript fragment reading Code pattern
Be able to read a short JavaScript fragment and spot where untrusted input is inserted into a page without sanitising.
Example: 'element.innerHTML = userInput is unsafe.'
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Short answer: Short answer (2 to 4 marks): define, outline or explain it and tie it to the scenario.
Related past questions: Familiarisation Q11a (1 mark): Cross-site scripting; Familiarisation Q11b (2 marks): Cross-site scripting
Memorise: SQL: HSC syntax and must-know queries
Shell script pattern Code pattern
A script is a text file of commands run in order, e.g. mkdir site, cd site, touch index.html, cp, rm, cat, grep.
Example: 'mkdir site && cd site && touch index.html'
- Code reading: Code or algorithm reading: interpret a fragment and state its output or purpose.
- Multiple choice: Multiple choice: pick the option that matches the definition or example.
Memorise: SQL: HSC syntax and must-know queries