IB Computer Science – Cheat Sheet (Exam
Revision)
1. Arithmetic Operators
Symbol Meaning Example
+ Addition 3+5=8
- Subtraction 7-2=5
* Multiplication 4 * 6 = 24
/ Division (real) 7 / 2 = 3.5
DIV Integer division 7 DIV 2 = 3
MOD Modulo (remainder) 7 MOD 2 = 1
^ Power 2^3=8
√x Square root √9 = 3
ABS(x) Absolute value ABS(-7) = 7
ROUND(x) Round ROUND(3.6) = 4
FLOOR(x) Round down FLOOR(3.9) = 3
CEIL(x) Round up CEIL(3.1) = 4
2. Relational Operators
Symbol Meaning Example
= Equal 5 = 5 (True)
≠ or != Not equal 5 ≠ 3 (True)
> Greater than 7 > 2 (True)
< Less than 4 < 9 (True)
>= Greater or equal 5 >= 5 (True)
<= Less or equal 3 <= 7 (True)
3. Logical Operators
Symbol Meaning Example
AND Both true (A > 3) AND (B < 5)
OR At least one true (X=10) OR (Y=20)
NOT Negation NOT (A=5)
4. Array Operations
Function Meaning Example
LENGTH(arr) Length of array LENGTH([2,4,6])=3
arr[i] Access element arr[0] = 2
APPEND(arr,x) Add element to end [1,2]→[1,2,3]
INSERT(arr,i,x) Insert at position [1,3]→[1,2,3]
REMOVE(arr,i) Remove element [1,2,3]→[1,3]
5. String Functions
Function Meaning Example
LENGTH(str) Length of string LENGTH("IB")=2
SUBSTRING(s,i,j) Substring from pos i, len j SUBSTRING("HELLO",2,3)="ELL"
CONCAT(s1,s2) Concatenate CONCAT("Hi","!")="Hi!"
UPPER(str) Uppercase "ib"→"IB"
LOWER(str) Lowercase "TOK"→"tok"
6. Control Structures
Keyword Meaning
IF … THEN … ELSE Conditional branching
LOOP / WHILE Loop while condition true
FOR Loop fixed times
OUTPUT Display output
INPUT Read input