paper 1 Flashcards

1
Q

What is in structured programming?

A
  • decomposing into manageable sub tasks, which can be written individually as sub routines
  • modularising (using subroutines)
    *using parameters
    *using return variables
    *using local variables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why use structured programming?

A
  • easier to test structured programs as each module can be tested individually
  • individual subroutines can be fixed and updated, without affecting the rest of the program
  • the subroutines can be re-used for future programs
  • programmers can work on one program, as each module can be written individually
    *coding may be easier
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is authentication?

A

the process of check a user is who they say

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

What is INPUT validation?

A

checks that the data meets a certain criteria before passing into the program

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

What are the types of input validation?

A

*range: checks that the data is within a specific range
*presence: checks that data has actually been entered
*format: checks that the data has the correct format
*look-up: checks the data against a table of acceptance values
*length: checks the data correct length

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

why should programs be easy to maintain?

A
  • change parts of the source code, without the risk of causing problems elsewhere in the code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you improve the maintainability of the code?

A

*comments explaining key features
*indentation to clearly see the flow of the program
*only using global variables where necessary, as they affect the rest of the code, variables with local scope will not affect the rest program, when other programmers change this variable it won’t affect the other part so he program
*variable names are enough for the reader to understand

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

What are the different types of errors?

A

*syntax error
*logical error

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

What is a syntax error?

A

When the compiler or interpreter doesn’t understand something you have typed because it doesn’t follow the rules or grammar of the programming language

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

How would you use the python in range function for pseudocode?

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

Why are meaningful identifiers names used?

A

Describes the purpose of the variable
makes the code easier to understand and maintain

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

What are the different types of test data ?

A

🟢normal data
🟢boundary valid data
🟢boundary invalid data
🟢erroneous data

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

What are trace tables ?

A

Helps to find logical errors

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

What is time efficiency in algorithms?

A

Measures things like the number of time memory was accessed and the number of CPU cycles taken to execute commands

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

Define ‘algorithm’

A

The sequence of steps that can be followed to complete a task

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

Define decomposition

A

The breaking of a problem into a number of sub problems, so that each sub problems accomplishes an identifiable task, which might itself be further subdivided

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

“Abstraction “

A

The process of removing unnecessary detail from a problem

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

Why are data types used?

A

Each data type is allocated a different amount of memory, using the correct data types makes the code more memory efficient, robust and predictable

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

Define constants

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

Define variables

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

What is an algorithm?

A

An algorithm is a sequence of steps that can be followed to complete a task.

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

What is decomposition?

A

Breaking a complex problem into sub problems until each task is manageable, then solving each one individually

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

What is abstraction?

A

Removing unnecessary detail from a problem so you are left with important bits, simplifying the task

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

What is algorithmic thinking?

A

A logical way of getting from the problem to the solution. Acknowledging if certain bits of code can be reused

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

What must you always do in pseudocode?

A

Declare variables

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

What is efficiency in programming?

A

How much time is needed to a run a particular algorithm and how much space is needed

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

Which one is more efficient a bubble sort or a merge sort?

A

A merge sort

Splits and then merges instead of swapping each pair

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

Which is more efficient binary search or a linear search?

A

Binary search
Only when list is ordered
Keeps on cutting of half rather than checking each number

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

How would you address questions about abstraction?

A

1-definition
2-important detail
3-unnecessary detail

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

How do you address questions about decomposition?

A

1- definition

2- two questions you can think of to sub section

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

What is considered ‘time’ in programming?

A

How may number of times memory was accessed

The number of CPU cycles taken to execute the command

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

is a computer program an algorithm ?

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

Why use the correct data types?

A

As each data type is allocated a different amount of memory , using the correct data types makes the code more memory efficient , robust and predictable

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

What is program flow ?

A

The order in which statements are executed in a program

  • can be controlled used selection and iteration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Write a pseudocode that creates a 6 digit username.
With the first 3 letters being from town first three letters
Then the second 2 digits being their current age
The last digit is the last letter of their surname

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

Why use meaningful identifiers ?

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

What are arrays ?

A

A data structure where data values of the same type are stored and defined under one variable name.

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

Why are subroutines good ?

A

🔵can be tested individually making it easier to debug .
🔵can be recalled many times within the program , rather than repeating sections of code (more efficient)
🔵can be stored as separate modules and reused in other programs

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

What is a local variable

A

A variable that can only be used within the structure that they have been declared .
✅cannot and are not affected by anything outside a subroutine (same variable name can be used elsewhere )
✅✅

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

What is a data type?

A

Specification is what type of value a variable has.

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

What are the five data types?

A

Integer
Real/float
Character
String
Boolean

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

What is an integer?

A

A numerical data type for whole numbers
2/4 bytes

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

What is a real/float ?

A

A numerical data type for decimal numbers
4/8 bytes

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

What is a character?

A

A single alphanumerical symbol
1 byte

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

What is a string?

A

A data type for one or more alphanumerical characters.
* can be a number or string
1 byte for each character

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

What is a Boolean?

A

A data type that can only take one of two values - TRUE or FALSE
1 bit-1 byte

47
Q

What is the difference between constants and variables?

A

Variables can be changed throughout out the program.

48
Q

What is iteration?

A

Loops controlled by conditions

49
Q

What are types of indefinite iteration?

A

Only rely on a condition(can be infinite):
Repeat until- condition at end, run at least once
While- condition at the start of loop
Do while

50
Q

What is selection?

A

Causes the program to make a choice and flow in a given direction

51
Q

What is a variable?

A

A named piece of memory that holds a value , can change as the program is running

52
Q

What is a constant?

A

A named piece of memory where the value cannot be changed while a program runs

53
Q

What is a type of selection?

A

An if else statement

54
Q

What is definite iteration?

A

A loop that repeats a set number of times - usually a for loop

55
Q

What is a nested statement ?

A

An iteration or selection made up of multiple statements inside each other

56
Q

What is the need for meaningful identifiers?

A

Suitable names for variables, makes it easier for the next person to work on the code to understand

57
Q

How do you find the length of a string?

A

LEN(string)
*starts from 1
🐍len(string)

58
Q

How do you find the position of a string?

A

POSITION(string,character)
*includes the 0
🐍 string.index(‘x’)

59
Q

How do you take a certain part of the string?

A

SUBSTRING(x ,y ,string)
*includes the 0
*does include last number
🐍string[x : y]
*does not include last number

60
Q

How do you concatenate strings?

A

+
Does not include spaces
Normally done with variables
🐍everything has to be a string

61
Q

How do you change one data type to another?

A

STRING_TO_INT (“your mom”)
STRING_TO_REAL (“your mom “)
INT_TO_STRING (69)
REAL_TO_STRING (9.58)
🐍
str()
int()
float()

62
Q

How do you get the quotient (whole number)?

A

DIV
🐍//

63
Q

How do you get the remainder?

A

MOD
🐍%

64
Q

What is not equal to

A

!=

65
Q

What is equal to , comparatively?

A

==

66
Q

What are subroutines?

A

A set of code within a program , that can be called any time from the man program

67
Q

What are the advantages of subroutines?

A

✅can be tested individually, making it easier to debug
✅can be used throughout the program repeatedly, however code only has to be written once = shorter programs
✅can be saved separately as modules , and reused in other programs = saving time

68
Q

How are subroutines done in Python and pseudocode ?

A
69
Q

What are global and local variables?

A

Global = can be used throughout the program , at any time
Local = can only be used within the structure they are declared in
*less memory

70
Q

What are parameters ?

A

A special variable , that passes data into the subroutine
*local scope

71
Q

1-D |rrays in python and pseudocode

A

Used to store multiple data values.
A a variable with a single identifier
*index begins at zero for both python and pseudocode

72
Q

How do you calculate the length of an array in pseudo code and python ?

A
73
Q

2D arrays

A
74
Q

How do you calculate length in arrays?

A
75
Q

How do you access all values within a 2D array?

A
76
Q

How do you write a for loop in python and pseudocode ?

A
77
Q

What are records?

A

Basically a dara structure (array), that can store items with different data types
Each record is an individual list in the list of lists 9rows’0
Columns are known as fields, each field is declared with a variable

78
Q

How do you make a record in python (dictionary) and pseudocode?

A
79
Q

What is a data structure ?

A

A format, for storing multiple data values under one variable name

80
Q

What is validation?

A

Checking that data meets certain criterias before passing the program.
It reduces the data entry errors , and prevents the ro gram from crashing if inalienable data is input

81
Q

What are the types of validation?

A

Presence check
Format check
Range check
Look up table
Length check

82
Q

What is authentication?

A

Checking the identity of a user

83
Q

What is a syntax error?

A

When the compiler/interpreter doesn’t understand something , because it doesn’t follow the rules or grammar of the programming language

84
Q

What is a logic error

A

When the compiler/ interpreters are able to run the code, but the code does something unexpected

85
Q

What are the types of testing data ?

A

Normal
Erroneous
Boundary/ extreme:
Boundary valid & boundary invalid

86
Q

What are some benefits of the structured approach ?

A
87
Q

what are some benefits of arrays

A

Arrays help maintain large sets of data under a single variable name to avoid confusion that can occur when using several variables

88
Q

What are the two search algorithms?

A

🟢Binary search
🟢Linear search

89
Q

What are the two sort algorithms?

A

🔵bubble sort
🔵merge sort

90
Q

describe binary search

A
91
Q

Binary search pseudocode code and python

A
92
Q

What is the pseudo code for binary search

A
93
Q

Describe merge sort

A
94
Q

Describe bubble sort

A
95
Q

What is the pseudo code for a bubble sort

A
96
Q

Merge sort advantages and disadvantages

A
97
Q

FOR loop (definite iteration )
Python V pseudocode

A
98
Q

Subroutines (procedures and functions)
Python V pseudocode

A
99
Q

Arrays (1D & 2D)
Pseudocode vs Python

A
100
Q

How do you convert a character into an ASCII value ?

A

ord()

print (ord(65))
= 65

101
Q

How do you convert an ACII value into a character?

A

chr()
print(chr(97))

=a

102
Q

Describe a linear search

A

Starts at the beginning of the array
Compares each element until the value being searched for is found, or until the end of the array is reached

103
Q

What makes an algorithm “more efficient “?

A

🟢fewer variables
🟢fewer instructions, will take up less memory
🟢will execute in less time

104
Q

What should be avoided when writing your own programs?

A

Not using compounded if statements
Instead of an if inside an if use AND
Instead of an elif inside an if use OR

Trying to avoid flag variables : have the whole condition presented within the while statement

105
Q

How do you declare FOR loops in pseudocode?

A
106
Q

Length in array for pseudocode

A
107
Q

How do you declare records in pseudocode?

A
108
Q

Random number generation for pseudocode

A
109
Q

How do you declare records in python ?

A
110
Q

How do you find the position of a character in python?

A
111
Q

What is the string to character conversion in python?

A
112
Q

Random number generation in python

A
113
Q

How do you substring an array in python?

A
114
Q

what are some things to remember within the exam?

A
  • to use <= instead of the pseudocode syntax
  • using a colon after the brackets
  • trying to use boolean operators as much as posible