OCR a level computer science 2.2.1

0.0(0)
studied byStudied by 1 person
0.0(0)
full-widthCall with Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/70

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

71 Terms

1
New cards

What meant by the term IDE (integrated development environment)?

A (single) program used for developing programs made from a number of components

2
New cards

What is an IDE?

An integrated development environment (IDE) is a software that helps programmers write, compile, and test their programs.

3
New cards

Entering a program in an IDE

- add line numbers

- automatically indent code

- auto-complete commands

- comment or un-comment a region

4
New cards

Debugging Facilities

- Set a breakpoint in the program which will cause the program to stop on that line

- set a watch on a variable so that it's value is displayed every time it changes

- step through a program one line at a time

- trace the execution of a program - for example display a message every time a particular statement is executed or subroutine is called

5
New cards

Features found in an IDE that will help programmers find any bugs in their code

- debugging tools

- code can be examined while it is running

- step through code

- insertion of a breakpoint

- autocomplete - which will predict the variable / built-in functions

- colour coding - to be able to distinguish between the different parts of each statement

- auto indent - to automatically indent code when selection/iterative statements have been used

6
New cards

What is an algorithm?

A sequence of instructions that can be followed to solve a problem e.g. recipe for a cake, knitting a jumper, directions from a to b

7
New cards

What is pseudocode?

Used to work out steps in a program before sitting down to write the code

8
New cards

What is an identifier?

A name e.g. score, that points to a memory location

9
New cards

What is an assignment?

Assigning a value to the memory location

10
New cards

Naming variables

- descriptive and clear

- use camel case

- avoid ambiguity

- consistency matters

- reverse keywords

- short and sweet

11
New cards

The value of a variable...

Can be changed while the program is running

12
New cards

The value of a constant...

Never changes

13
New cards

What is a nested if statement?

an if statement within an if statement.

The second condition is only checked if the first condition is true

14
New cards

Complex Boolean expressions

AND = returns true if both conditions are true

OR = returns true if either of the conditions are true

NOT = a true expression becomes false and vise versa

15
New cards

If....then...endif

If the condition is true then one or more statements are executed

16
New cards

If...then...else...endif

Often alternative statements need to be executed if the given condition is not met

17
New cards

If...then...elseif...else...endif

Use multiple if...then...else statements to evaluate more than one condition

18
New cards

Switch/case...endswitch

A switch/case statement is the logical equivalent of the if....then...else...endif statement

- it is used to make it easier to code multiple condition checks

- some languages do not have a switch/case statement

19
New cards

What does iteration mean?

repetition

20
New cards

What is iteration?

a sequence of instructions being repeated multiple times

21
New cards

What is branching?

Decides which code is run/only runs code once

22
New cards

While...endwhile loop

The condition is tested upon entry to the loop, it is possible that the instructions inside the loop might not be executed at all if the entry condition is not met

23
New cards

Do...until loop

The statements in the loop are executed before the condition is evaluated

24
New cards

For...next loop

- The for...next loop is termed 'definite iteration', and is used to repeat a block of instructions a specified number of times

- uses a counter variable which is automatically incremented each time through the loop

- optionally, a step value can be specified to make the counter increase or decrease by any integer

25
New cards

Nested for... next loop

Useful for looping through grids in two-dimensional arrays, which will be covered later

26
New cards

What is a function?

A subroutine that can be called to perform a task or operation and aways returns a value. They can be called in an expression or be assigned to a variable

27
New cards

What is a procedure?

A subroutine that can be called by simply writing its name in the code

28
New cards

Difference between functions and procedures

Functions return a value, procedures dont

29
New cards

What is a subroutine?

A named block of code containing a set of instructions

30
New cards

Passing arguments

Arguments in parentheses are used to pass data to a subroutine

31
New cards

Define the term parameter

- (A description of) an item of data

That is passed to a subroutine (when it is called)

- It is used as a variable within the

subroutine

32
New cards

Parameters appear in...

Subroutine definitions

33
New cards

Arguments appear in...

Subroutine calls

34
New cards

What is passing by value?

A copy of the value is passed to the subroutine and discarded at the end, therefore, Its value outside of the subroutine will be unaffected/unchanged

35
New cards

What is passing by reference?

The address of the parameter is given to the subroutine so the value of the parameter will be updated (changed) at the given address

36
New cards

What is scope?

The section of code in which the variable is available

37
New cards

What is the scope of a local variable?

The subroutine in which it is declared

38
New cards

What is a local variable?

A variable that is declared within a function and cannot be accessed by statements that are outside of the function

39
New cards

What is a global variable?

A variable that is defined in the main program and can be used In any subroutine called from the main program

40
New cards

Describe the use of local variables

- Defined within one module...

... accessible only in that module

- Can be used as parameters

- Data is lost at end of module

- Same variable name can be used in

other modules without overwriting

values/causing errors

- Can overwrite global variables (with the

same name)

41
New cards

Advantages of local variables

•The subroutines will be independent of a particular program and can be re-used in different programs

•There is no chance of accidentally changing a variable in the main program that is used in a subroutine or vice versa

•Keep your subroutines self-contained!

•Pass as arguments any values that are needed

42
New cards

Disadvantages of local variables

- Repeatedly creating and destroying local variables within a loop or recursive function can incur unnecessary memory overhead

- excessive use of local variables within deeply nested blocks can lead to code clutter and reduce code readability

43
New cards

Advantages of global variables

- Only need to be declared once

- you don't need to keep passing the parameters between the different modules

44
New cards

Disadvantages of global variables

- They are always stored in memory while the program is running which can use up memory

- makes the program difficult to maintain as it's difficult to understand where variables are changed in the program

45
New cards

What is modular programming?

A programming technique used to split large, complex programs into smaller, self contained modules

46
New cards

Advantages of modular programming

- Programs are more easily and quickly written

- Large programs are broken down into subtasks that are easier to program and manage

- Each module can be individually tested

- Modules can be re-used several times in a program

- Large programs are much easier to debug and maintain

47
New cards

What is a procedural programming language?

A high level language which gives a series of instructions in a logical order

48
New cards

What is recursion?

A programming technique in which a method calls itself.

49
New cards

The essential characteristics of a recursive routine?

- a stopping condition/base case (when met, means the routine will not call itself)

- for input values other than the stopping condition, the routine must call itself

- the stopping condition must be reached after a finite number of calls

50
New cards

Recursive vs iterative

- a recursive routine can cause a 'stack overflow' error

- a recursive routine has fewer lines of code

- a recursive routine is easier to follow

- an iterative routine is faster than a recursive routine

51
New cards

What is a class?

A blueprint for an object. It defines what an object will look like (it's properties/attributes) and what it can do (it's methods)

52
New cards

Three main sections of a class

- Class name

- Attributes

- Methods

53
New cards

Attributes are normally set as...

Private

54
New cards

Methods are usually declared as...

Public

55
New cards

What is encapsulation?

The bundling of data with the methods that operate on and restrict direct access to it

56
New cards

What does encapsulation do?

Wraps the attributes and methods in the class definition, hiding details of the implementation from the user

57
New cards

What does data hiding mean?

A programmer who defines an object in a class cannot directly access or change an attribute of the object, it has to be done via a getter or setter method

58
New cards

What is an object?

an instance (example/case) of a class

59
New cards

What is a constructor?

A method used to create a new object in a class

60
New cards

What is instantiation?

Creating new objects from a class

61
New cards

What is inheritance?

Allows a class to inherit the properties and behaviours of another class

62
New cards

Inheritance can...

Quickly and easily reuse code from a class and extend its attributes and methods without effecting the original code

63
New cards

Subclass

Uses superclass as a basis, but include some more functionality specific to enemies

64
New cards

Over-riding

When a method is redefined in the subclass with the same name and same arguments

65
New cards

What is aggregation?

The ability to store one object inside of another object

66
New cards

Benefits of OOP

- once you define a class, it becomes very easy to reuse that class and create hundreds of objects of that class

- unnecessary details can be abstracted away from in the implementation of the methods (I.e you don't need to know a method works to be able to use it)

- code reuse

- encapsulation reduces code complexity

- easier to modify and maintain

67
New cards

What is polymorphism?

The ability of a programming language to process objects differently depending on their class

68
New cards

Two types of polymorphism

Static and dynamic

69
New cards

Static Polymorphism

Allows you to implement multiple methods of the same name but with different parameters - within the same class (this process is known as overloading)

70
New cards

Dynamic polymorphism

Runtime polymorphism - multiple methods can be defined with the same name and signature in the subclass and superclass. The call to an overridden method are resolved at runtime

71
New cards

Static VS dynamic polymorphism