Paper 1 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Selection?

A

IF….ELSE

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

Iteration?

A

FOR….ENDFOR
WHILE….ENDWHILE
REPEAT…UNTIL

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

4 different sorts?

A

Linear search
Bubble sort
Merge sort

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

What is FOR…ENDFOR loop an example of?

A

definite iteration

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

What is WHILE…ENDWHILE loop an example of?

A

indefinite iteration

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

What is REPEAT…UNTIL loop an example of?

A

indefinite iteration

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

What is a subroutine?

A

A named, self-contained section of code that performs a specific task.

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

What are the 2 different types of subroutines?

A
  1. procedures (nothing is returned)
  2. functions (always returns a value using RETURN)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are advantages of subroutines?

A
  1. easier to de-bug
  2. more robust
  3. Decomposing large problems into sub-tasks, making the problem easier to solve
  4. Each subroutine can be tester separately
  5. Can be used several times within a program
  6. Maintenance is easier
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define global variable?

A

A global variable is one which is declared in the main program and is recognised in al subroutines called from the main program.

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

Define local variable.

A

Declared within the subroutine and only existing whole the function is being executed. Not recognised anywhere else in the program.

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

Advantages of using local variables

A
  • keeps the subroutine self-contained. Can be used in any program and there will be no confusion over which variable names in the main program might conflict with names used in a subroutine.
  • Easier to debug and maintain
  • If memory space is an issue, the use of local variables will save on memory as the space used by local variables is freed up when the subroutine completes
  • form of abstraction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to make a code more understandable?

A
  • Use comments to say the purpose of the program/ explain how any difficult bit of code works
  • Split the program into subroutines which each perform a single well-defined task
  • Use meaningful variables
  • Use indentation so that it is clear where iteration and selection statements end
  • Use constant variables for values such as VAT rate
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a syntax error?

A
  • spelling mistake (prnt instead of print)
  • missing key words out of constructs such as starting REPEAT loop but not writing UNTIL anywhere
  • opening brackets but not closing them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are logic errors?

A
  • missing brackets for mathematical equations
  • Loops that do not execute the correct number of times because a condition is written wrong e.g x > 10 instead of x >= 10
  • variables have not been initialised or are initialised in the wrong place
  • flawed algorithms that don’t do what they were intended too
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define low-level language

A

Machine code and assembly language

17
Q

What is high-level language?

A

Coding platforms like python, java etc

18
Q

What are advantage of high-level language?

A
  • relatively easy to learn and are much faster to program in
  • because it looks like english it is easy to read, understand, debug and maintain
  • designed to make programming quick and easy for particular applications
19
Q

Advantages of low-level languages

A

Often used in embedded systems

  • gives the programmer complete control over the system components so it can be used to control and manipulate specific hardware components
  • Very efficient code can be written for a particular type of processor, so it will occupy less memory and execute faster than a compiled high-level language
20
Q

Differences between machine code and assembly code

A

Machine code is the code executed by the processor, and consists only of 0s and 1s. In assembly language, have to be translated into machine code before they can be executed.

21
Q

What is an assembler?

A

An assembler converts assembly language into machine code. High level language -> Assembly code (assembler) -> Machine code

22
Q

How to make a program more robust?

A

Add validation

23
Q

Advantage to stuctured approach?

A
  • easier to read as program is split into smaller parts/subroutines
  • easier to debug as program is split into smaller parts/subroutines
24
Q

Limitation to array

A

Only stores one data type

25
Q

Why are nested loops needed for 2D arrays?

A

To access each row, then for each row the inner row can access each item

26
Q

How do 2D arrays make use of multiple indexes?

A

One index is used for each row and a second for each item

27
Q

Difference between static and dynamic arrays?

A

Dynamic array - can change size as values can be added/removed

Static array - set size

28
Q

What is the difference between writing to an array and appending to an array?

A

Writing changes an item whereas append adds value to end of array

29
Q

3 methods of accessing files in python?

A
  1. READ
  2. WRITE
  3. APPEND
30
Q
A