STUDY GUIDE · GKU 2

Programming study guide (Artificial Intelligence)

Every AI method in this degree ends up as a program, usually in Python. This unit makes sure you can read and write that program without guessing: what each data type does in an expression, how loops and functions run step by step, how data gets in and out of files, and which mistakes a type system catches before the program runs. The second half moves from single functions to design: the functional and object-oriented styles, class hierarchies and dynamic dispatch, encapsulation, and the iterators and whole-array operations (NumPy, pandas) that AI code is built from. Each section opens with a quick-revision card, and worked examples are traced line by line, the way the exam asks.

Structured by the official ETEC subject standard for this topic: every listed topic and learning outcome, with formulas, figures and worked examples. The full sections are available to members in the app.

SKU 2.1 · Fundamentals of programming

  1. Basic programming concepts and data types

    Variables as names bound to objects; numbers, strings, booleans and None; integer and real division in Python, Java and C; floating-point rounding; and the built-in containers list, tuple, dict and set, with the aliasing they cause.

  2. Control structures: conditionals and loops

    if/elif/else, while and for loops, break, continue and the loop else clause; counting iterations exactly, including nested loops, by hand and by formula.

  3. Functions, parameter passing and recursion

    Defining functions with default and keyword arguments, local and global scope, how Python passes arguments (call by sharing) compared with C's call by value and pointers, and recursion traced through its call tree.

  4. User and file input/output, and handling errors

    input and print with formatting, opening files in the right mode, reading line by line, why closing (or with) matters, and catching the exceptions that I/O raises.

  5. Program errors detected by a type system

    Static and dynamic type checking, the typing rules for arithmetic and assignment, which conversions are implicit (widening) and which need a cast (narrowing), and how to read a type-error message and fix the code.

SKU 2.2 · Object-oriented and functional programming

  1. The functional approach compared with the object-oriented approach

    Objects that bundle mutable state with methods against pure functions over immutable data: map, filter and reduce, lambdas and closures, and when each style fits AI code.

  2. Class hierarchies: inheritance, reuse and subtyping

    Designing a small hierarchy of predictors in Python: an abstract base class, subclasses that reuse its code through inheritance and super(), and the substitutability rule that makes a subclass a true subtype.

  3. Control flow by dynamic dispatch

    How a method call picks its body from the object's run-time class, how this replaces chains of type tests, Python's method resolution order with multiple inheritance, and overloading versus overriding in Java.

  4. Object-oriented encapsulation mechanisms

    Keeping an object's state valid by hiding it behind methods: Java's access modifiers, Python's naming conventions and name mangling, properties with validating setters, and the class invariants they protect.

  5. Iterators and operations on aggregates across languages

    The iterator protocol and generators, the same filter–map–reduce pipeline in Python, Java and JavaScript, the cost of common operations on lists, sets and dicts, and whole-array operations in NumPy and pandas.

MORE ARTIFICIAL INTELLIGENCE GUIDES

All study guides

Read the full guide beside your practice questions.

Open the app