Practical

READ SUMMARY
READ PAST YEAR PAPERS

READ JUPYTER NOTEBOOK MEMORISE

H2 Computing Class Notes (tutorials)

  • CANNOT use break, pass, continue. Use while loop.

Pseudo-Code Guide

  • CANNOT use slicing, range, for char in string, etc
PseudocodePython
ENDIF/FOR/WHILE/FUNCTION-
ELSE IF
(ENDIF after the set of IF + ELSE IF + ELSE)
ELIF
INPUT / OUTPUT Xx = input(“...”)
print(x)
Array[i, j]
Fixed size array (set the size, initialise?)
List[i][j]
Append to array
list[i] ← valueAppend to list
DECLARE array with size, data type, etc
E.g.
DECLARE names: ARRAY[1:6] of STRING
⇒ array starts from 1
MAXSIZE = 40
DECLARE scores: ARRAY[0:MAXSIZE-1] of INTEGERS
⇒ array starts from 0
DECLARE scores: ARRAY[1:6, 1:4] of INTEGER
DECLARE avgs: ARRAY[1:6] of REAL
DECLARE total: ARRAY[1:4] of INTEGER
BEGIN FUNCTION grades2rp(grades:STRING) RETURNS BOOLEAN
ENDFUNCTION
REPEAT UNTIL ⇒ run at least once, then check condition
DO WHILE ⇒ check condition first before running
FUNCTION ⇒ returns something
PROCEDURE ⇒ does not return
-
FOR i = 0 TO length(list) - 1
string[i], list[i]
for char in string
for item in list
for i ← 0 to 9for i in range(10)
^**
//#
DIV//
MOD%
x ← x + 1x += 1
-String methods
temp = ‘ ’
for i ← 0 to 4
temp ← temp + str[i]
String/list slicing [:]

rafael’s notes: CP - Complete Notes

ernest’s notes: Computing Notes

jerome’s solutions for mr loh’s CPs: Computing Solutions

IDLE ⇒ Help ⇒ Python docs

Practical: put data file in same folder, don’t use file path

COPY (not move, else may accidentally edit / delete) the files to your own output folder

Display / Output = print NOT return

PRINT for error statements

WRITE COMMENTS on code for practical

CLOSE FILES

Remove codes / comments used for debugging and re-run

OOP

  • Use private attributes
  • Use get methods e.g.
    getName(self):
return self._name
  • No need set methods

  • Set parameters = None as initialisation in init

  • No need set methods

  • Set parameters = None as initialisation in init