paper 2 Flashcards

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

decomposition

A

Decomposition: Breaking down a problem into smaller parts which are easier to understand. These smaller parts can be individually solved as they are easier to comprehend, for example creating an app would need graphics, audio, software used to create it, testers, user interface…

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

abstraction

A

Abstraction: filtering out and ignoring the parts of problems which are not needed to solve a problem. It is effectively a general overview of the program with specific details removed, for example, the London Underground map.

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

algorithmic thinking

A

Identifying the steps involved in solving a problem.

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

algorithm

A

An algorithm is a step-by-step set of instructions used to solve a problem. Before designing an algorithm, it must be decomposed into its inputs, outputs and the order of instructions, as well as if any decisions need to be made.

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

how can algorithms be made

A

pseudocode
flowcharts
high level language

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

flowchart symbols

A

Lines represent the flow of the program.
Parallelograms show inputs and outputs.
A rectangle shows a process, for example, x = x + 10
A diamond represents a decision, for example, if x > y. Then there would be 2 lines coming from this, one for yes and one for no.
A rectangle with curved sides represents a terminal, such as the start or end of the program.

subroutine - square with lines on ends.
Sequence that performs a specific task. You can use this within your flowchart to show more detail in a specific section

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

avanatge flowchart

A

Advantages of using flowcharts include the fact that they show a step-by-step method of how to solve a program, which can be easily written.

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

disavantage flowchart

A

Disadvantages of flowcharts include that they may be time-consuming to make and not easily drawn.

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

avantage pseudocode

A

The advantages of using pseudocode include it acts as the foundation for transcribing it into an actual programming language and is easy to understand with an English-like syntax, making it easy for non-programmers as well. Errors in the design will not affect the program as it is obvious what the intended result is, and if there is an obvious error this can be easily changed.

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

disavantge pseudocode

A

Disadvantages include that it can be harder to see how a program flows with indentation, and is just more time-consuming to make than a flowchart, so you might as well use Python for that.

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

trace table

A

A trace table is a table used to show how values in variables change throughout instructions occurring.

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

what goes where in trace table

A

In the columns goes the variable name. In the rows, the instruction number is written. Below the variable names, in the table, are the expected values of what each instruction does.

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

when does logic error occur on trace table

A

A logic error occurs if the expected value on paper does not equal the received value when executed by the program.

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

linear search

A

The simplest method of searching through a dataset. It gets the length of a dataset and sets it counter to 0. It looks at the position of its counter and sees if it matches the search. If not, the counter is incremented by 1 and the process is repeated

Linear searches work on unordered lists. On ordered lists, they will take a long time if the value to search for is a large number.

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

binary search

A

Binary search is used on a dataset of ordered numbers. It works by:

getting the midpoint in the list, getting the value, and if it is the target value the search ends.
If not, it will compare the received value. If the value is less than the value to be found, it will disregard the lower half of the list, as it knows it cannot be lower than the midpoint value.
The remaining part of the list is divided in half again, and the process is repeated.
When the value is found, the search has succeeded.

Binary searches are much more efficient than linear searches, especially on large datasets.

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

what is sequence

A

Sequence refers to the order in which the code is executed.

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

bubble sort

A

Start at the beginning of the list, compare the value at position 1 to the next one up (at position 2).
Swap the positions of these if the second is bigger than the first.
Then, move both positions up one, to position 2 and 3.
Swap if they are in the wrong order.
Repeat until the end of the list.
Start back from the beginning and repeat this until it is in order.

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

basic programming definiitinos

A

Variables: A value stored in memory that can change.
Constants: A value stored in memory that cannot change once defined.
Operators: Logic applied to numbers, e.g. equal, subtract, less than.
Inputs: data inputted to programs. In Python, x = input(“enter string: “)
Outputs: data the program shows to users. print(“output”)
Assignment: giving a value data. e.g. x = 2. You are assigning the value x to the data, which is 2, an integer.

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

what is selection

A

Where a choice is made in a program depending on a condition or outcome

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

pattern recognition

A

used to identify where the constructs such as selection and iteration could be used, where functions and procedures can be reused, reuse code from past programs to carry out similar functions in new program.

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

merge sort

A

Split the list in half repeatedly until all values are separate
Compares two values next to each other and organise.
Go to the next pair of values and repeat. If something is smaller than the existing smallest value, then place it there instead. (Same with biggest values)
Repeat until all values are in order

large data sets better w/ merge sorts as theyre more efficient

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

insertion sort

A

More efficient than bubble sort, but less complex and efficient than a merge sort

Compare values of 1 and 2.
If 1 is bigger than 2, then 2 is moved to the start.
Compare the values of 2 and 3. Move 3 to the left until it cannot be moved any more as the number is smaller than it.
Repeat for all values.
Insertion sorts work best when used with smaller data sets.

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

what is iteration

A

Iteration is a loop. There are count and condition-controlled loops.

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

whats !=

A

!=
Not equal to. Only True when the value it is comparing against is NOT the first value.

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

opoerators

A

There are comparison and arithmetic operators. (They will give the boolean value of True if their criteria are met)

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

count conrolled loops

A

Count-controlled loops are controlled by a number. For example, if x > 10: will run until the value of x is greater than 10.

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

whats <

A

<
Less than. Only True when the value in front of it is less than the value after it. if x < 3 means if x is less than 3.

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

whats >

A

> Greater than. Only True when the value in front of it is more than the value after it. if x > 3 means if x is greater than 3.

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

condition controlled loops

A

Condition-controlled loops are controlled by a specific value. This is most often True or False; these will run until this value is changed. For example, if x == True: will run the code until the value ofx is no longer equal to True.

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

what is ==

A

==
Equal to. Used only to check if a value is something else. Do not get confused with a single equals which is used to specify a value.

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

whats <=

A

<=
Less than or equal to. Only True when the value in front of it is less OR equal to the value after it.

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

what are: ==, !=, <, >, <=, >=

A

compariosn operators

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

data types

A

Integer: Positive or negative whole numbers
Real/float: Numbers with decimal places
Boolean: True or False (1 or 0)
Character: A single character
String: Numbers and letters together.

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

how to obtain length of string using string manipulation

A

The length of a string can be obtained by doing len(string), where string is a variable holding a string value.

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

whats >=

A

> =
Greater than or equal to. Only True when the value in front of it is more OR equal to the value after it.

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

boolean operators

A

AND - only True when the two values are True.
OR - only True if one or more values are True.
NOT - everything that is not the value.

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

arithmetic operators

A

+ Addition. 9 + 10 = 21
- Subtraction.
* Multiplication.
/
Division.
MOD is Modulus. Gives the remainder. 20 mod 8 = 4. (16 remainder 4)
DIV is Quotient. Gives how many times the number can be fully divided. 20 div 8 = 2. (20 divided by 8 is 2 remainder 4.)
^ is Exponentiation. To the power of. 2^8 = 256.

39
Q

whast casting

A

Casting is a method used to convert between these data types. For example, if you want to compare a user’s input to a value, you must change it to an integer first

40
Q

what is slicing

A

To get the characters from positions 0 and 3 (not included), the syntax is this: x[0:3] = would be ‘Bag’. This is known as ‘slicing’.

41
Q

concatenation

A

Finally, concatenation is joining two strings together.
If one = “Baguette” and two = “Brigaders”, then one + “ “ + two would print Baguette Brigaders.

42
Q

how 2 get character at specific point in string

A

You can also get the characters at a specific point in a string. If x = ‘Baguette’, then x[3] would be ‘u’. Remember that 0 is your first value in a list/array.

43
Q

how to manipulate casing of a string

A

You can also manipulate the casing of everything in a string. If x = ‘Baguette’, then x = x.upper() would result in x being ‘BAGUETTE’. Likewise, x.lower()would be ‘baguette’.

44
Q

arrays

A

arrays store lots of stuff and are denoted by their square brackets, like [4, 5, 3, 6, 9]
They can be accessed by the string name and location in the list. If the above list with strings is called random_words, then to print the word ‘Baguettes’ I would call print(random_words[2]).

45
Q

2d arrays

A

2D arrays take this principle and make it more complicated. Basically, this means there is an array inside an array

eg: list_of_cars_and_prices = [[“beans car”, “bozo car”, “fresh car”], [20, 30, 55]]

print(list_of_cars_and_prices[1][2]. This gets the third value from the second array, inside the list called ‘list_of_cars_and_prices’. This can be used to store values next to each other.

46
Q

procedures vs functions

A

A procedure performs a task, whereas a function produces information.

47
Q

file handling

A

writing:

file1 = open(“file.txt”)
x = file1.write(“Hello! This is a file!”)
file1.close()

Reading back the contents:

file1 = open(“file.txt”)
x = file1.read()
file1.close()

print(x)

> > > Hello! This is a file!

It’s best practice to always do file.close() to avoid file corruption.

48
Q

parameters

A

Parameters can be invoked into both functions and procedures. For example, beans(number_of_beans) will result in the function or procedure using the invoked value of number_of_beans to perform a calculation.

49
Q

functions

A

Functions return a value. You can assign a value to a variable and set this value to the result of a function, like x = beans(), where beans is a defined function. It could return a number or string or any data type.

50
Q

global variables

A

Global variables can be accessed by every subroutine at all times. Present in memory during execution. They aren’t good because if it gets maliciously changed, or changes unintentionally, then it will affect the entire code and every subroutine. Also, it can use a lot of memory if many variables are used at once - normal in big programs and games. The scope of these is the entire program.

51
Q

local variables

A

Local variables are declared in one subroutine or function. The value of this is only held in memory whilst that specific part of the code (i.e. the subroutine) is being executed. Therefore, it’s more efficient. The scope of these is the sub-program of declaration.

52
Q

anticipating misuse

A

A way of making sure age is not negative could be by making the part of the code that verifies age a function, which will return the age once verified to be valid. For example, a while statement could be added with a condition-controlled loop, which will only change conditions if age > 10 AND age < 100. This is an example of input validation

53
Q

randoms

A

You must import random at the start of the program for this to work (it is a module).

random.randint(lower_bound, upper_bound) is used to generate a random number between bounds. Assign this to a variable and you have your randomly generated number.

54
Q

parameter passing

A

Parameter passing - allows the values of local variables within the main program to be passed to sub-programs without the need to use global variables. The value of these variables (or a copy of the value of these variables) is passed as a parameter to and from sub-programs as necessary.

55
Q

sql (how can data be retrieved w/ it, what is it)

A

SQL is a programming language used for interrogating a database.

Data can be retrieved using the commands SELECT, FROM and WHERE

  • stands for wildcard, which means all records.
56
Q

authentication

A

Usernames and passwords. This can be easily implemented by adding password = input(“enter password”) and using double equals to check if it matches a previously defined variable, or even decrypted from an external file.

57
Q

subroutines

A

These are parts of the main program. If one part of the program needs to be changed, it can be in the subroutine which is called, so other parts of the code are not affected by changes. Also, it can reduce the amount of clutter in code: if something needs to happen multiple times, code can just link back to a pre-existing subroutine.

58
Q

why is testing done

A

Testing is used to make sure there are no bugs or unexpected events when the code is run.

59
Q

ways of ensuring code is mainntainable in the future

A

subroutines
naming conventions
indentation
commenting

60
Q

logic errors

A

errors that result in a result the programmer did not expect/intend to get

the code can still run if there are logic errors

61
Q

commenting

A

helps people read your code and helps you come back to work on it later.

62
Q

naming conventions

A

There is a set of rules you should follow when naming variables and subroutines. For example, naming something x doesn’t really tell you what it does, whereas value_inputted will.

63
Q

indentation

A

Essential for legibility, indentation also defines if statements and more. It also makes it easier to read what parts of the program do, as indented levels show that everything on that indent is a result of something previously.

64
Q

iterative testing

A

This is testing the code, or parts of it, during development to ensure there are no seriously buggy things happening as a result of a typo. It may be easier to identify the mistake if the code is run every few minutes, as the programmer will remember what they’ve changed.

65
Q

normal test data

A

Normal test data is data which should be accepted by a program, without causing errors

66
Q

terminal testing

A

This is testing which occurs at the end of production of some code, before being sent to clients.

67
Q

syntax errors

A

Syntax errors are errors which break the grammatical rules of the programming language and stop it from being run/translated into machine code.

68
Q

the 2 examples of tests

A

iterative
terminal

69
Q

boundary test data

A

Boundary test data is data of the correct type which is on the very edge of being valid. For example, in the statement if x > 10, the boundary would be 10.

70
Q

invalid test data

A

Invalid test data is data of the correct data type which should be rejected by a computer system. This could be like if an age is -100 years old.

71
Q

and or not gates

A

An AND gate will only output 1 if both its inputs are 1 as well.
An OR gate will only output 1 if one or more of its inputs are 1.
A NOT gate will only output 1 if its input is 0. (Essentially reversing the input)

72
Q

categories of programming language

A

high and low-level languages.

73
Q

high level lang

A

They are easy to read and write, and some have a human-like syntax. They also do not depend on the physical architecture of the processors executing them. However, as they are machine independent, they must be translated in order to run.

examples: python, java

74
Q

erroneous test data

A

Erroneous test data is data of the incorrect data type which should be rejected by a computer system. This could be entering a name instead of an age.

75
Q

xor gate

A

when number of true inputs is odd, gives a 1. else gives 0.

e.g if 2 inputs, xor only gives result of 1 if 1 input is true

76
Q

compiler

A

A compiler parses the source code once, saving the results as a binary file, and translating it

77
Q

low level lang

A

Low-level languages like assembly code and machine code. They must be changed depending on the make and model of the CPU. As they run ‘closer’ to the CPU itself, they often require less overhead on tasks, and machine code does not require translation as it is written purely in binary.

78
Q

interpreter

A

An interpreter reads the source code line by line and converts it to executable binary while executing.

79
Q

compiled code

A

Compiled code runs faster, as they have already been translated. If the code has no logic or syntax errors and does not need to be debugged, compiled code is always better. It optimises code as well, allowing it to take up less memory. For example, comments are removed when generating compiled code. However, compiled code may also only be on the hardware and OS it is targeted to. You can’t run an EXE file on your phone without an IDE.

80
Q

interpreted code

A

Interpreted code is slower, as the CPU must wait for every line to be translated, but has the potential to run on multiple kinds of hardware, running different operating systems. It simply executes code, without saving a machine code version. They require less memory also as they do not translate the entire file.

81
Q

what does ide have to help programmers

A

The IDE (integrated development environment) has a wide range of tools to help programmers develop programs. These include:

Editors. Code can be edited.
Error diagnostics. Tracebacks can show what caused exactly what to fail at the exact line.
Run-time environment. This allows a program to run on a computer even if it was not designed to. This allows the programmer to just use their known high-level language, and the RTE will do the rest.
Translators. They translate code to be executed.

82
Q

what else do ides have

A

Breakpoints - code can be stopped at a specific line and variables can be checked for logic errors
Auto-correct and indent
Autosuggestion - can sometimes fix a problem automatically
Syntax highlighting - similar declarations can be coloured to see them better. For example, all variables could be yellow while classes are blue.
Linting - the IDE can analyse the code you’re writing as you’re writing it for errors. For example, it may recognise that you used a double equals instead of a singular equals for setting the value of a variable.

83
Q

run time error

A

More difficult to spot as it can run a program without reporting an error. E.g. runs but
Doesn’t give an output. Or the program hangs or Becomes inactive

84
Q

data validation

A

check to ensure that the data entered is sensible and reasonable. It does not check the accuracy of data.

85
Q

data sanitation

A

Trims or strips strings, removing unwanted characters to make sure it contains only permitted characters . E.g. Da%ve the % would be removed.

86
Q

anticipating misuse

A

Defensive program design will consider and anticipate misuse. Misuse may be in the form of a brute force attack on the program.

87
Q

contingency planning

A

Once a programmer has anticipated the misuse they can then plan for the these issues.

88
Q

assembler

A

Translates Assembly language into machine code

89
Q

whast ide

A

A software application that provides all the facilities to computer programmers for developing programs. It normally consists of a source code editor, build automation tools and a debugger

90
Q

asembly lang

A

Assembly language is often used in the programs used by embedded systems
They are used to write device drivers and real-time systems where speed is essential.
Assembly language is specific to each type of CPU. Programs written for one type cannot be used on others.

91
Q

check digit (data validation)

A

last few digits used to see if code is correct

92
Q

spell check

A

check words in dictionary, if spelt wrong is wrong

93
Q

null eror - testing

A

cheking what happens if nothing is put in

94
Q

defensive desig considerations

A

validation

sanitisation

authentication

maintenance

testing