INB270 – Programming
Lecture 2 – Week 2
The following notes are for the first lecture, starting from approximately page 40 of
the lecture slides, as this information was not reached in the first lecture in week 1.
Input is always stored in the memory of the computer, or in other words, in a
Each variable will have a name, a type and an assigned value.
Variables are restricted based on what their type is. Variables must be
declared before use, or they will simply not exist in the program. Variable
types also determine how the value is stored in memory, and what type of
operations can be applied to that variable.
Variable types include integer (a whole number), double (numbers with a
decimal place) and Boolean (either true or false).
The remainder of the notes here are from the second lecture’s slides.
In addition to the first three items on the list of things computers can do,
computers can do basic maths (addition, subtraction, multiplication, division),
they can compare two values and make a decision, and they can repeatedly
execute a sequence of instructions.
When writing code, it is important to give variables meaningful names so that
it is easier to identify what the variable is when reading the code back. It is
important to note that