1.1 Fundamentals of programming Flashcards

1
Q

Define a memory address

A

A specific location in memory where instructions or data are stored

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define assignment

A

The process of giving a value to a variable or constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between a constant and a variable?

A

A constant is an item of data whose value does not change, whereas a variable is an item of data whose value could change whilst the program is being run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define debugging

A

The process of finding and correcting errors in programs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define declaration

A

The process of defining variables and constants in terms of their name and data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why is naming variables important?

A
  • Makes it easier to debug / find and correct errors in the code
  • When several programmers are working on the same program at once, sensible naming conventions can make it easier to understand
  • It is easier to update the program at a later date
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a data type?

A

A data type determines what sort of data is being stored and how it will be handled by the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define an integer

A

An integer is any whole positive or negative number including 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define a real / float

A

A number with a fractional or decimal part

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define a string

A

A string is a data type used to store characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define boolean

A

A data type with 2 possible states of True or False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a pointer?

A

A data item that identifies a particular element in a data structure - normally the front or rear

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an array?

A

A set of related data items stored under a single identifier. Can work on one or more dimensions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is an element?

A

A single value within a set or a list - also called a member

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Define a record

A

One line of a text file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between a built in and a user defined data type?

A

Built in data types are pre-defined by the programming language, whereas user defined data types are created by the programmer for use in the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Why are user defined data types useful?

A
  • They can make code more efficient and can allow for reusing sections of code
  • They can make code easier to read and understand
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Define syntax

A

The rules of how words are used within a given language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Define selection and give an example

A

The principle of choosing what action to take based on certain criteria, in python this is an if statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Define nesting

A

Placing one set of instructions within another set of instructions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Define iteration

A

The principle of repeating processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Define definite iteration and give an example

A

A process that repeats a set number of times, in python this is a for loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Define indefinite iteration and give an example

A

A process that repeats until a certain condition is met, in python this is a while loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a sequence?

A

The principle of putting correct instructions in the right order within a program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Define arithmetic operations

A

Common expressions such as +, -, x, /

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Define rounding

A

Reducing the number of digits used to represent a number while maintaining a value that is approximately equivalent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Define truncating

A

The process of cutting off a number after a certain number of characters or decimal places

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is the difference between random and pseudo-random number generation?

A

Random numbers are generated by a function that produces a completely random number whereas pseudo-random numbers are not 100% random, and are common in programming languages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Define a relational operation

A

A relational operation is an expression which compares two values such as equal to or greater than

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Define a boolean operation

A

An expression that results in a True or False value

31
Q

What are the 4 main boolean operators?

A
  • AND: outputs True if both inputs are True
  • OR: outputs True if at least one input is True
  • NOT: inverts the input such that True becomes False and vice versa
  • XOR: outputs True if only one input is True, but not both
32
Q

Define string handling functions

A

A string handling function is one which can be carried out on sequences of characters

33
Q

Define character code

A

A binary representation of a particular letter, number, or special character

34
Q

Define event

A

Something that happens when a program is being run

35
Q

Why are subroutines useful?

A
  • They can be called at any time using their unique name
  • They allow you to gain an overview about how the program is put together
  • You can use a top-down approach to develop the whole project
  • The program is easier to test and debug as each subroutine is self contained
  • Very large projects can be developed by more than one programmer
36
Q

What is the difference between a function, a subroutine, and a procedure?

A

Subroutine is the most general term, referring to a collection of processes. A function is a type of subroutine which returns a value, whereas a procedure does not return any value

37
Q

Define module

A

A module is a number of subroutines that form part of a program

38
Q

What are the benefits of using functions in a program?

A
  • Storing complex processes as functions can make code easier to read as it allows them to all be stored in one location, with each reference in the body of the code being short and easy to read
  • If you want to edit the function, this only has to be performed in one location rather than in any instance of the function
  • For large algorithms that are going to be reused in several places in the code, writing this as a function will be more efficient as it saves the whole function being rewritten each time
39
Q

What is functional programming?

A

Functional programming is a programming paradigm which uses functions to create programs

40
Q

Define parameter

A

A parameter is data being passed into a subroutine, this behaves like a variable and is a general name referring to the specific value in each individual case

41
Q

Define argument

A

An item of data being passed into a subroutine, this refers to the actual value being passed in

42
Q

Define block interface

A

Code that describes the data being passed from one subroutine to another

43
Q

What is the difference between a local and a global variable?

A

A local variable is specific to the subroutine in which it is declared - local variables in different subroutines can have the same names and not affect each other - whereas global variables apply across the whole code and can be accessed and changed at any point within a program

44
Q

What are the advantages of local variables?

A
  • You can’t accidentally change a value already being used in the program
  • You can use the same variable names in different sections of the program without it referring to the same value
  • Memory is saved as local variables are removed from memory after use
45
Q

Define exception handling

A

The process of dealing with events that cause the current subroutine to stop

46
Q

What is a hierarchy chart?

A

A diagram that shows the design of a system from the top down

47
Q

What is a structure chart?

A

Similar to a hierarchy chart but additionally contains information showing how data is passed around the system

48
Q

What is the top down approach?

A

When a system is designed starting at the top of a process and working your way down into smaller sub-processes

49
Q

Define procedural programming languages

A

Languages where the programmer specifies the steps that must be carried out in order to achieve a result

50
Q

Define imperative programming languages

A

Languages based on giving the computer commands or procedures to follow

51
Q

Give an example of the overall hierarchy of a program

A
  • Programs are made up of modules
  • Modules are made up of subroutines and functions
  • Subroutines and functions are made up of algorithms
  • Algorithms are made up of lines of code
  • Lines of code are made up of statements, instructions, and data
52
Q

Define flowchart

A

A flowchart is a diagram using standard symbols that describes a process or system

53
Q

Define system flowchart

A

A diagram that shows individual processes within a system

54
Q

Define pseudo-code

A

A method of writing code which is not specific to a particular programming language

55
Q

What are naming conventions?

A

Naming conventions are the processes of giving meaningful names to subroutines, functions, variables, and other user-defined features within a program

56
Q

What is modular design?

A

Modular design is a method of system design that breaks a whole system down into smaller units or modules

57
Q

What are the advantages of an object-oriented approach?

A
  • Programs are written in modules which makes editing easier as only the relevant module will need editing
  • It is easy to add functionality by adding a new module
  • Modular design makes it easy for several programmers to work on a project at once on separate self-contained modules
  • Objects can inherit attributes and behaviours making code reusable
  • Changes to data are made within an object rather than the overall program
  • Libraries can be created to allow for the easy reuse of code
58
Q

Define encapsulation

A

The concept of putting properties, methods, and data in one object

59
Q

What is a method?

A

The code or routines contained within a class designed to perform particular tasks on data within the object

60
Q

Define properties

A

The defining features of an object or class in terms of its data

61
Q

Define class

A

Defines the properties and methods of a group of similar objects

62
Q

Define object

A

A specific instance of a class

63
Q

Define inheritance

A

The concept that properties and methods in one class can be shared with a subclass. Within the subclass, features can be added or pre-existing features can be changed, but not deleted

64
Q

What is a class diagram?

A

A way of representing the relationship between classes

65
Q

Describe a class diagram

A
  • Hierarchical in structure with base class at the top and sub-classes beneath
  • Sub-class inherits properties and methods of base class
  • Arrows show direction of inheritance
  • Each class is a box of 3 sections, one each for name, properties, and methods
66
Q

Define instantiation

A

The process of creating an object from a class

67
Q

Define polymorphism

A

The ability of different types of data to be manipulated with the same method

68
Q

Define overriding

A

Where a method described in the sub-class takes precedence over one with the same name in the base class

69
Q

What are the 3 different ways methods can be set up?

A
  • Static: the method can be used without an object of the class being instantiated
  • Virtual: the method is defined in the base class but can be overridden in the sub-class where it is used, this is a feature of polymorphism
  • Abstract: the method is not in the base class and must be provided in the sub-class
70
Q

Define aggregation

A

Aggregation is a method of creating new objects that contain existing objects

71
Q

What is composition aggregation?

A

Creating an object which contains other objects, and will cease to exist if the containing object is destroyed

72
Q

What is association aggregation?

A

Creating an object that contains other object, which continue to exist even if the containing object is destroyed

73
Q

What are the 3 key design principle of object-oriented programming?

A
  • Encapsulate what varies: everything that varies should be put into its own class, so properties and methods are split into as many classes as needed to represent the real-life scenario
  • Favour composition over inheritance: using composition or aggregation to combine existing objects is much less error prone than inheritance and should be favoured where possible
  • Program to interfaces, not implementation: programs should be written around the interface that is created through the defining of methods and classes, rather than the implementation of these interfaces