Programming Fundamentals
Data types
| Type | Example | Stores |
|---|---|---|
| Integer | 5 | whole number |
| Real / Float | 5.7 | decimal |
| Boolean | True / False | logical |
| Character | 'A' | one symbol |
| String | "hello" | text |
Variables vs constants
- Variable – a named store whose value can change while running.
- Constant – set once, never changes (e.g.
VAT = 0.2). Improves readability and safety.
Assignment & casting
age ← 15 # assignment
price ← float("3.50") # cast string → real
text ← str(age) # cast int → string
Operators
Arithmetic: + - * / ^(power) MOD DIV
Comparison: == != < > <= >=
Boolean: AND OR NOT
MOD= remainder:7 MOD 3 = 1DIV= integer division:7 DIV 3 = 2
The three constructs
1. Sequence – steps in order
2. Selection – IF decisions
3. Iteration – loops
Exam tip
MOD (remainder) and DIV (whole part) are heavily tested. 15 MOD 2 = 1 is a common way to test if a number is odd/even.