(P1) Fundamentals of Programming Flashcards
What is a data type?
Data types are defined by the values it can take or the operations that can be performed on it.
What is an integer?
A whole number, positive or negative. Including zero.
What is a real/float number?
A positive or negative number which can have a fractional part.
What is a boolean value?
Value which is either true or false.
What is a character?
A single number, letter or symbol.
What is a string?
A collection of characters.
What is the data type ‘data/time’?
Way of storing a point in time, many different formats are used.
What is a pointer/reference?
Way of storing memory addresses.
What is a record?
Collection of fields, each of which could have a different data type. Rows from a table.
What is an array?
An indexed set of related elements each of which has the same data type.
What is variable declaration?
Creating a variable for the first time, giving it a name and sometimes a data type. This allocates a portion of the computer’s memory to the variable.
What is constant declaration?
Creating a constant for the first time, giving it a name and a data type. The value of the constant does not change while the program is running.
What is assignment?
Giving a constant or variable a value.
What is iteration?
Repeating an instruction, this could be definite or indefinite.
What is selection?
Comparing values and choosing an action based on those values.
What is a subroutine?
A named block of code containing a set of instructions designed to perform a frequently used operation.
Give two examples of iteration.
For loop
While loop
What is definite iteration?
Iteration in which the number of repetitions required is known before the loop starts.
What is indefinite iteration?
Iteration in which the number of repetitions required is not known before the loops starts.
Give an example of definite iteration.
For loop.
Give an example of indefinite iteration.
While loop.
What does it mean if code is ‘nested’ and how can you identify it.
Nested: One structure is placed within another.
Identified by indentations.
How can you make your code easier to understand?
Use indentations.
Choose sensible indentifier names.
What does the operation real/float division do?
When one value is divided by another, both a quotient and the remainder are returned.
What does the operation Modulo do?
Returns the remainder of an integer division.
Why can constants be more useful than variables?
When the constant is required multiple times throughout the code. If the constant needs to be changed then it only needs to be updated in one place.
What is concatention?
Joining two or more strings together to form a new string.
Why can a computer never truly generate a random number?
Computer generated numbers are pseudo-random, which means they use a mathematical formula.
When might an error be ‘thrown’?
Using the wrong data type.
Dividing by zero.
Accessing non-existent elements in an array.
What does the computer do once an error has been ‘thrown’?
Handles the exception to avoid crashing by:
Pausing execution of program.
Saving the current volatile state of the program on the stack system.
Running code called ‘catch block’.