0 All Topics Flashcards

1
Q

Describe what happens in the “fetch” part of the fetch-execute cycle? (3)

A
  1. The address of the instruction to be fetched is placed into the MAR. 2. The instruction is fetched from memory. 3. The instruction is transferred to the MDR.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe what happens in the “decode” part of the fetch-execute cycle? (1)

A

The computer decodes the instruction by deciding which instruction should be carried out.

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

Describe what happens in the “execute” part of the fetch-execute cycle? (1)

A
  1. The decoded instruction is then executed so that the CPU performs continuously
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe what happens at the end of the fetch execute cycle? (2)

A
  1. The process is repeated 2. The program counter is incremented
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What operations does the ALU perform? (1)

A
  1. Arithmetic and logic operations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the Control Unit (CU) do? (1)

A

Manages the FDE Cycle

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

What is a CPU register? (1)

A
  1. The section of high-speed memory within the CPU that stores data to be processed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

State two features of the MAR? (2)

A
  1. It is a register 2. It stores a single address
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the function of the MAR? (2)

A
  1. Stores the address of the instruction or data that is going to be fetched 2. Holds the address in memory where data is going to be transferred to
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the function of the MDR? (1)

A
  1. Stores the fetched instruction/ the instruction to be processed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the function of the Program Counter? (1)

A
  1. Stores the address of the next (or current) instruction to be run
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the function of the Accumulator? (1)

A
  1. Stores the result of calculations/processes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why does cache size affect the performance of the CPU (2)

A

Data is transferred faster (1) Makes the CPU more efficient (1)

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

How can having a higher processor affect the performance of the CPU (2)

A

Faster/ Higher clock speed (1) More Fetch Execute Cycles (1) More Instructions can be executed per second

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

Explain why having a quad- core processor will not always run twice as fast as a dual- core processor (3)

A

Software may be designed to run 1 core and not multiple (1) Dual core may have a faster clock speed than a quad core (1) Quad core may have less RAM (1) Quad core may have less cache (1)

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

What is Cache Memory (2)

A

High speed memory inside the processor (1) that stores frequently used insructions (1)

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

Define what is meant by an ‘embedded system’ (1)

A

A computer system that is built into another device (1)

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

Identify 3 devices that contain embedded systems (3)

A

Sat Nav (1) Dishwasher (1) MP3 player (1) Washing machine (1) Manufacturing equipment (1)

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

Identify 2 characteristics of an embedded system (2)

A

They have limited functions (1) and are often built into larger machines (1)

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

What is primary memory? (1)

A

Memory directly accessed by the CPU.

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

What are the two types of primary memory? (2)

A

RAM (1) ROM (1)

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

What is the purpose of ROM? (3)

A

Stores BIOS (1) Stores boot up instructions (1) Stores data that should not be changed (1)

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

Is ROM volatile or non volatile? (1)

A

Non volatile (1)

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

What is the purpose of RAM? (2)

A

Stores currently running programs (1) and data (1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Is RAM volatile or non volatile? (1)
Volatile (1)
26
Why do computers need virtual memory? (2)
When RAM is full (1) secondary storage is used as temporary RAM (1)
27
How does virtual memory work? (4)
When RAM is full (1) data from RAM is moved to secondary storage to make space (1) RAM can then be filled with new data (1) When data in virtual memory is needed it is moved back to RAM (1)
28
Why is secondary storage needed on a computer system? (2)
To store files (1) including when the computer is turned off (1)
29
What are the characteristics of Magnetic Disk Storage e.g. HDD? (3)
Large capacity (1) relatively cheap (1) sensitive to movement due to moving parts (1)
30
What are the characteristics of Solid State (flash) storage? (3)
Lower capacity (1) relatively expensive (1) no moving parts so not sensitive to movement (1)
31
What are the characteristics of Optical Disc storage? (3)
Low capacity (1) very cheap per disc (1) moving parts so can't be moved while running (1)
32
List the 6 characteristics of secondary storage. (6)
Cost Capacity Reliability Speed Portability Durability (Computers Can Really Store Petabytes of Data)
33
What are the three types of secondary storage? (3)
Magnetic Disk (1) Optical Disk (1) Solid State (1)
34
Why does data need to be stored as binary? (1)
Computers can only understand binary (1)
35
How do you calculate the size of a sound file? (3)
Sample rate (1) x duration in seconds (1) x bit depth (1)
36
How do you calculate the size of an image file? (3)
Colour depth (1) x image height in pixels (1) x image width in pixels (1)
37
How do you calculate the size of a text file? (2)
Bits per character (1) x number of characters (1)
38
What are the units of file sizes, smallest to largest? (8)
Bit Nibble Byte Kilobyte Megabyte Gigabyte Terabyte Petabyte
39
How many bits in a byte? (1)
8
40
How many bits in a nibble? (1)
4
41
How do you convert from a unit of file size to a larger unit?
Divide by 1000 per step (unless it's nibbles or bits to byte)
42
How do you convert from a unit of file size to a smaller unit?
Multiply by 1000 per step (unless it's bytes to nibble / bit)
43
What is 0101 in denary? (1)
5
44
What is 11001111 in denary? (1)
207
45
What is 151 in binary? (2)
10010111 (1 mark per nibble)
46
What are the rules of binary addition? (4)
0 + 0 = 0. 0 + 1 = 1. 1 + 1 = 0 carry 1. 1 + 1 + 1 = 1 carry 1.
47
What is an overflow error? (2)
An extra carry bit (1) that cannot fit into the bits provided (1).
48
Convert 39 from hexadecimal to denary (1)
57
49
Convert 203 from denary to hexadecimal (2)
CB (one mark per digit)
50
Convert 10010011 from binary to hexadecimal (2)
93 (one mark per digit)
51
Convert FA from hexadecimal to binary (2)
11111010 (one mark per nibble)
52
How can you multiply a binary number by 2? (1)
Move all of the bits 1 place to the left.
53
How can you divide a binary number by 2? (1)
Move all the bits 1 place to the right.
54
What is a character set? (1)
The characters a computer system understands / displays.
55
How many potential characters can you store with a byte? (1)
256
56
How many potential characters can you store with 7 bits? (1)
128
57
How many characters can ASCII represent? (1)
128
58
How many characters can Unicode represent? (1)
256
59
If the binary code for "A" was 65 what would be the code for "D"?
68
60
Describe how a character set would be used to store the string "Hello world!" (2)
Each character in a character set has a unique binary value. (1) The binary values of each character are recalled in order. (1)
61
How are images stored in binary? (3)
The image is split up into pixels. (1) Each pixel is given a binary code. (1) Which represents the colour of that pixel. (1)
62
What is metadata? (1)
Data about data. Data about an image / sound file.
63
What might metadata store about an image? (2)
Height (1) width (1) colour depth (1) resolution (1) author (1)
64
What is the impact of increasing colour depth on an image file? (2)
More colours will be available (1) file size will increase (1)
65
What is the impact of increasing resolution of an image file? (2)
More pixels will be used, increasing the detail of the image. (1) The file size will increase (1)
66
How is sound stored in binary? (2)
The height of the sound wave is sampled at regular intervals (1) and converted to binary (1)
67
What is the impact of increasing the bit depth on an audio file? (2)
The sound reproduced will be closer to the original (1) but file size will increase (1)
68
What is the impact of increasing the sample rate of an audio file? (2)
The wavelength is sampled more often so the sound reproduced will be closer to the original (1) but file size will increase (1)
69
Why is compression useful? (2)
It reduces file size (1) so files take less space on secondary storage (1)
70
What are the benefits of lossy compression? (4)
Lossy means the decompressed file is not identical to the original (1) however the difference is unlikely to be noticed by humans. (1) Lossy will decrease file size (1) so files are easier to store or send. (1)
71
What are the benefits of lossless compression? (2)
Lossless means the decompressed file is identical to the original. (1) The file size will decrease, but not as much as lossy. (1)
72
What are the two types of network? (2)
LAN (Local Area Network) & WAN (Wide Area Network)
73
What is a LAN? (2)
Computers connected together (1) in a small geographic area (1)
74
What is a WAN? (2)
A network over a large geographic area (1) that uses external hardware or the internet (1)
75
What are three factors that would affect the performance of a network? (3)
Bandwidth of network (1) number of devices connected (1) distance to WAP if wireless (1)
76
What is the role of a switch? (2)
It connects devices on a network (1) using MAC addresses (1)
77
What is the role of a router? (2)
It connects networks together eg network to internet (1) using IP addresses.
78
What is the role of a wireless access point (WAP)? (1)
It broadcasts a wireless signal allowing devices to communicate with a network (1)
79
What is the role of the NIC? (2)
Stores the device's MAC address (1) allows the device to connect to networks (1)
80
What are the key features of a Peer to Peer (P2P) network? (4)
Devices are directly connected to each other (1) devices are independent / equal (1) devices install software / updates individually (1) if any device fails the remainder can continue (1)
81
What are the key features of a Client / Server network? (4)
Devices are connected via a switch (1) software and updates can be installed from a central machine (1) requires a specialist to set up (1) hard to add new nodes (1)
82
Name a wired mode of connection (1)
Ethernet(1)
83
Name two wireless connection methods (2)
Wi-fi (1) Bluetooth (1)
84
What is encryption? (3)
An algorithm(1) that disguises data (1) so it can only be understood by authorised users (1)
85
Give three features of an IP(v4) address (3)
4 bytes long (1) normally written in denary (1) configured in software (1).
86
Give three features of an IP(v6) address (3)
16 bytes long (1) normally written in hex (1) configured in software (1).
87
Give three features of a MAC address (3)
6 bytes long(1) normally written in hex (1) configured by hardware (1).
88
Which addressing mode is used to route data over the internet? (1)
IP addressing (1)
89
Which addressing mode is used to route data within a LAN? (1)
MAC addressing (1)
90
What are standards? (1)
Rules that allow hardware and software made by different providers to interact (1). Eg Ethernet or HTML
91
What is a network protocol? (1)
A set of rules for data transmission (1)
92
What is TCP / IP used for? (2)
IP finds the address of a device (1) TCP transfers data (1)
93
What is HTTP used for? (1)
Transmitting websites (HTML) (1)
94
What is HTTPS used for? (1)
Transmits websites securely (1) using encryption (1)
95
What is a layer in a network protocol? (1)
A division of network functionality (1) (This means it's one part of the algorithms that make a network run)
96
What are the advantages of splitting a network protocol into layers? (4)
Layers are self contained (1) which allows different developers to concentrate on one aspect of the network. (1) A layer can be taken out and edited without affecting other layers (1) which means different vendors and systems can work together. (1)
97
What is FTP? (2)
File Transfer Protocol (1) transfers files using client / server. (1)
98
What is POP? (3)
Post Office Protocol. (1) An email protocol (1) that delivers an e-mail and doesn't keep a copy on a server. (1)
99
What is IMAP? (3)
Instant Message Access Protocol. (1) An email protocol (1) that allows a user to access emails stored on a server. (1)
100
What is SMTP? (3)
Simple Mail Transfer Protocol. (1) An email protocol (1) for sending emails. (1)
101
What are the internet protocols we've learned? (3)
HTTP (1) HTTPS (1) FTP (1)
102
Which protocol is used to connect devices on wired networks? (1)
Ethernet(1)
103
What are the email protocols we've learned? (3)
POP3 (1) IMAP (1) SMTP (1)
104
What is a brute force attack? (1)
A program attempting all possible combinations (1)
105
What is data interception? (1)
Data transmissions being read by unauthorised users or programs (1)
106
What is malware? (1)
Software that damages or deletes data (1)
107
What is phishing? (1)
Stealing data by tricking users (1)
108
What is SQL injection? (1)
Writing code in an input box to access data (1)
109
What are the network threats? (6)
Malware (1) Social engineering / Phishing (1) Brute-force attacks (1) Denial of service (DDoS) (1) Data interception (1) SQL injection (1)
110
What is a DDoS attack? (1)
Overloading a server with requests so it can't serve data (1)
111
How do you prevent a brute force attack? (3)
Use a strong password (1) limit number of password attempts (1) firewall (1)
112
How do you prevent data interception? (1)
Encryption (1)
113
How do you prevent a malware attack? (1)
Anti-virus (1)
114
How can you prevent phishing? (2)
Network policy (1) firewall (1)
115
What is penetration testing? (1)
Looking for security flaws in a network (1)
116
How can you protect against social engineering? (1)
Training (1)
117
How can you protect against DDoS? (2)
Use a proxy server (1) or a firewall (1)
118
What are the methods of protecting a network? (7)
Penetration testing (1) Anti-malware software (1) Firewalls (1) User access levels (1) passwords (1) encryption (1) physical security (1)
119
What is physical security? (2)
Methods to prevent access to hardware (1) eg locks on doors (1)
120
What are user access levels? (2)
A set of rules (1) that govern what users can do on a network (1)
121
What should a strong password include? (3)
At least one uppercase letter (1) lowercase letter (1) and number / symbol (1)
122
What are the roles of the operating system? (5)
User Interface (1) File management (1) User management (1) Memory management (1) Peripheral management (1)
123
What does the User Interface do? (2)
Displays output (1) to the user and allows them to interface with the hardware (1)
124
What is file management? (2)
Allocating space in secondary storage for files (1) allowing users to open and rename / delete / create etc. files (1)
125
What is user management? (3)
Creating user accounts and passwords (1) allocating space in memory for users' data (1) setting rules for what users are allowed to do (1)
126
What is memory management? (2)
Transfering data between different areas of memory (1) eg moving data from secondary storage to primary memory (1)
127
What is peripheral management? (1)
Allowing the user and operating system to interface with additional hardware (1)
128
What are device drivers? (1)
Software that allows an operating system to interface with peripheral devices (1)
129
What is multitasking? (1)
An operating system appearing to do several tasks at once (1)
130
What is multiprocessing? (1)
An operating system doing several tasks at once using a multi-core processor (1)
131
How is memory management used in multitasking? (2)
The instructions for the current task are moved into primary memory when needed (1) then moved out so other tasks can be completed (1)
132
List three features of a user interface (3)
A desktop where icons for programs can be arranged (1) windows to show file structures (1) menus to access applications (1)
133
What is utility software? (2)
Software that performs a specific task (1) to aid the computer in running (1)
134
What is encryption software? (3)
Software that disguises data (1) using an algorithm (1) so only authorised users can understand it (1)
135
What is the purpose of defragmentation software? (3)
Files on the hard disk are moved (1) so files are stored together (1) so fewer disk accesses are needed (1)
136
Why might a computer run faster after defragmentation software has run? (3)
It takes less time to access a file because the data is stored contiguously (together in order) (1) so the HDD doesn't need to move as far to read the next piece of data (1) because it will be in the next memory location (1)
137
Give three examples of utility programs (3)
Backup (1) Encryption (1) Compression (1) Firewall (1) anti-virus (1)
138
How does compression software reduce file size? (4)
It uses an algorithm (1) to remove repeated or unnecessary data (1) It could be lossy or lossless (1) lossy removes data permanently. Lossless means original file will be restored (1)
139
List 3 things you can do with a file management utility (3)
Place files in folders (1) rename folders (1) delete files (1) create folders. (1) etc.
140
What are the three laws we need to know for Computer science? (3)
The Data Protection Act 2018 (1) Computer Misuse Act 1990 (1) Copyright Designs and Patents act 1988 (1)
141
What are the two types of software licenses? (2)
Open source - anyone is able to see the code (1) and proprietary - users must pay to use the software. (1)
142
What are the key features of the Data Protection Act? (3)
Data collected must be accurate (1) must not be shared without consent (1) and must not be used unfairly (1)
143
What are the key features of the Computer Misuse Act? (2)
It is illegal to possess or use (1) tools to access unauthorised data (1)
144
What are the key features of the Copyright Designs and Patents Act? (2)
You own the rights to a creative product when you create it (1) other people or companies must get your permission to use it or face a fine (1)
145
What are the advantages to customers of using open source licensing? (2)
It's usually free to use (1) they can adapt it or add features (1)
146
What are the advantages to businesses of using a proprietary license? (2)
They can charge a fee to use it (1) They can restrict what users can do (1)
147
List three ways computers have a negative impact on the environment (3)
They use rare materials that must be dug out of the ground (1) they are made using toxic chemicals which must be disposed of (1) when they are thrown away they create e-waste (1)
148
List three ways computers have a positive impact on the environment (3)
They contribute to dematerialisation - reducing the amount of things people need (1) they allow research on green energy (1) they allow people to communicate digitally - reducing the need for paper and transport (1)
149
List three ways computers have a positive impact on culture (3)
They allow people to connect with other people anywhere in the world (1) They reduce loneliness through allowing easier contact (1) they allow art and cultural artefacts to be shared for free (1)
150
List three ways computers have a negative impact on culture (3)
They create the environment for cyberbullying (1) they expose people to online dangers e.g. phishing and malware (1) They encourage users to spend less time together in person which can lead to loneliness (1)
151
What are the four tools offered by IDEs? [4]
Translators [1] run time environments [1] editors [1] error diagnostics [1]
152
How does an editor in an IDE help a programmer write code? [4]
Autocomplete [1] colour highlighting [1] automatic indentation [1] stepping [1]
153
How does an IDE help a programmer diagnose errors [3]
Break points allow the code to stop at specific points [1] stepping allows the programmer to run the program line by line [1] error diagnostics tell the programmer the errors in the code [1]
154
What are the characteristics of high level languages? [3]
Close to english [1] work on a range of devices [1] need to be translated [1]
155
What are the characteristics of low level languages? [3]
Close to binary [1] may only work on one type of device [1] may not need to be translated [1]
156
Why does code need to be translated? [2]
The processor can only understand machine code. [1] code is usually not written in machine code, so needs to be translated. [1]
157
What are the characteristics of a compiler? [3]
Converts code to low level in one go [1] Creates an executable file [1] users have no access to source code once compiled [1]
158
What are the characteristics of an interpreter? [3]
Converts code to low level line by line [1] Stops running when it finds an error [1] It's usually quicker to interpret than to compile [1]
159
What is the purpose of testing? [3]
Check the program meets the user requirements [1] Check the program works as intended [1] Check the program doesn't crash when invalid values are entered [1]
160
What are the two times you can test a program? [2]
Iterative - during development. Testing while making changes [1] Final - when development is complete. [1]
161
What are the three types of test? [3]
Normal - valid data [1] Boundary - the edges of the valid data [1] Erroneous - invalid data [1]
162
What is a syntax error? [1]
An error that breaks the rules of the programming language [1]
163
What is a logic error? [2]
An error that will not stop the code from running [1] but produces an unexpected outcome [1]
164
How can code be made more maintainable? [4]
Comments [1] Indentation [1] Use of subroutines [1] Sensible variable names [1]
165
What is anticipating misuse? [2]
Predicting ways that users may break a system [1] and planning ways to prevent it [1]
166
What is authentication? [2]
Requiring a username and password [1] to prevent unauthorised access to data [1]
167
What is input validation? [2]
Checking that an input meets requirements [1] and is the right data type [1]
168
What is the purpose of a truth table? [2]
To predict all possible outputs [1] from a program given all possible inputs [1]
169
What are the three Boolean operators? [3]
AND [1] OR [1] NOT [1]
170
What is the rule for an AND gate? [1]
Both inputs must be True / 1 [1]
171
What is the rule for an OR gate? [1]
One or both inputs must be True / 1 [1]
172
What is the rule for a NOT gate? [1]
Input must be False [1] (A NOT gate flips the input)
173
Which gate is this? [1]
And [1]
174
Which gate is this? [1]
NOT [1]
175
Which gate is this? [1]
OR [1]
176
What would be the outcome of this gate if A was 1 and B was 0?
1
177
List the three SQL commands we need [3]
SELECT [1] FROM [1] WHERE [1]
178
What symbol means 'All' in SQL? [1]
*
179
What is the command to see all fields from the table 'users'?
SELECT * from users
180
What is the command to select the firstname and secondname fields from customers where the first name is 'Dave'?
SELECT firstname, secondname FROM customers WHERE firstname = 'Dave'
181
What is the command to select the username from users where age is greater than 13?
SELECT username FROM users WHERE age > 13
182
What are the three types of computational thinking? [3]
Abstraction [1] Decomposition [1] Algorithmic thinking [1]
183
What is abstraction? [2]
Removing unnecessary detail [1] to focus on the important parts of a problem [1]
184
What is decomposition? [2]
Breaking a large problem down into smaller problems [1] until the problems are small enough to solve [1]
185
What is algorithmic thinking? [2]
Structuring a problem so it can be solved by a computer [1] usually by making it quantitative [1]
186
What are the three programming constructs? [3]
Sequence [1] Selection [1] Iteration [1]
187
What is programming in sequence? [2]
Instructions in order [1] processed one after the other [1]
188
What is programming using iteration? [2]
Repeating sections of code [1] until conditions are met [1]
189
What is programming using selection? [2]
Choosing which code to run [1] based on a decision [1]
190
When writing an input in an algorithm what must we remember to do? [1]
Assign the input to a variable [1]
191
What is a structure diagram? [3]
A diagram that shows the problem you're solving at the top [1] then breaks the problem down into smaller problems below [1] then breaks those problems down into smaller problems etc [1]
192
Describe the steps a linear search would use to look for an item in a list [4]
Look at each item in order [1] starting at the beginning [1] until the item is found and the position of the item is returned [1] or the end of the list is reached and the search returns not found. [1]
193
What is the prerequisite for binary search data? [1]
It must be in order [1]
194
Describe the steps a binary search would use to look for an item in a list [5]
Find the middle of a list (round down if it would be a decimal) [1] If it's the number searched for, return the index of the number [1] If it is higher than the number, discard the middle number and lower half of list and repeat [1] If it is lower than the number, discard the middle number and the upper half of list and repeat. [1] If only one value is left and it's not the number we're looking for, the number is not in the list [1]
195
Complete a binary search for the number 7 in this data: 2 4 6 7 8
2 4 6 7 8 # Find middle number - 6. # 6 is lower than 7 so discard 6 and lower half of list. 7 8 # Find middle number - between 7 and 8, so go left # Middle number is 7. Return index of 7.
196
Describe the steps a merge sort would take to sort a list [4]
Split the list in half, then split the sub lists in half [1] until all numbers are in a list of length 1 [1] Combine the lists in pairs, in order [1] and repeat until all lists have been combined into a sorted list [1]
197
Complete a merge sort on this list: [2, 9, 1, 7, 3, 6]
[2, 9, 1] , [7, 3, 6] #Split the list in half. [2] [9,1] [7] [3,6] #Split again [2] [9] [1] [7] [3] [6] # Split again. All now on their own. [2,9], [1,7], [3,6] #Combine in pairs, in order. [1, 2, 7, 9], [3, 6] #Combine pairs, two at a time. [1, 2, 3, 6, 7, 9] #Sorted list
198
Describe the steps an insertion sort would take to sort a list [4]
Look at the second item of the list. [1] If it's smaller than the number to its left, move it left until it isn't [1]. Repeat with each other item in the list in order [1] until all items have been sorted. [1]
199
Complete an insertion sort on this list: [9, 3, 6, 2, 4]
9, 3, 6, 2, 4 #Initial list 3, 9, 6, 2, 4 # 3 moved left as it's smaller than 9. 3, 6, 9, 2, 4 # 6 moved left as it's smaller than 9, but stops as it's not smaller than 3. 2, 3, 6, 9, 4 # 2 moved left until it hits the start as it's smaller than 3, 6 and 9. 2, 3, 4, 6, 9 # 4 moved left as it's smaller than 9 and 6, but stops as it's not smaller than 3.
200
Describe the steps a bubble sort would take to sort a list [4]
Look at items 1 and 2 in the list. [1] If they're not in order, swap them. [1] Repeat the process, moving along by 1 each time until the end of the list is reached. [1] If any swaps have been made, go back to the start of the list and repeat. [1]
201
Show the steps a bubble sort would take to sort this list: 4, 5, 2, 3
4, 5, 2, 3 # Initial list (4, 5), 2, 3 # 4 and 5 are in order, so don't swap. 4, (2, 5), 3 # 5 and 2 are not in order, so swap. 4, 2, (3, 5) # 5 and 3 are not in order, so swap. #We made some swaps, so repeat the process. We don't need to look at the last number this time. (2, 4), 3, 5 # 4 and 2 are not in order, so swap. 2, (3, 4), 5 # 4 and 3 are not in order, so swap. #We made some swaps, so repeat the process. We don't need to look at the last two numbers this time. (2, 3), 4, 5 # 2 and 3 are in order, so don't swap. List is sorted.
202
Which algorithm is this? counter = 0 swapped = True swaps = 0 length = list.length while swapped == True while counter < length-1 if list[counter] > list[counter+1] then temp = list[counter] list[counter] = list[counter+1] list[counter+1] = temp swaps = swaps + 1 endif counter = counter + 1 endwhile if swaps == 0 then swapped = False else: swaps = 0 counter = 0 endif endwhile
Bubble sort
203
Which algorithm is this? find = 11 found = False length = list.length lowerBound = 0 upperBound = length while (lowerBound <= upperBound) midpoint = int((upperBound + lowerBound))/2 if list[midPoint] == find then print('Found at' , midpoint) found = True endif if list[midpoint]> find then upperBound = midpoint-1 else lowerBound = midpoint+1 endif endwhile if found == False then print('Not found') endif
Binary search
204
What is a variable? [2]
A location in memory [1] that stores a value [1]
205
What is a constant? [1]
A variable that should not be changed while the program is running [1]
206
What are the 5 data types for variables? [5]
Character, Real, Integer, Boolean, String
207
What is the operator for equal to?
==
208
What is the operator for not equal to?
!=
209
What is the operator for less than or equal to?
<=
210
What is the operator for greater than or equal to?
>=
211
What does MOD do?
Divides and gives the remainder, e.g. 5 MOD 2 = 1
212
What does DIV do?
Divides and discards the remainder, e.g. 3 DIV 2 = 2
213
What does the ^ operator do?
Exponentiation, e.g. 2 ^ 3 is 8
214
What is 9 MOD 5?
4
215
What is 7 DIV 2?
3
216
How would you write this statement in Python? If the user's age is greater than 12, but below 20.
if age > 12 and age < 20
217
How would you write this statement in Python? If the user's name is 'Dave' or 'Sarah'
if name == 'Dave' or name == 'Sarah'
218
Assign the value "Dave" to the variable name
name = "Dave"
219
Take a user's name as an input and assign it to the variable name.
name = input("Enter your name")
220
What is a count controlled loop? [3]
A loop that repeats [1] until a count is reached [1] a for loop. [1]
221
What is a condition controlled loop? [3]
A loop that repeats [1] while a condition is met [1] a while loop [1]
222
Is this code selection or iteration? while name != "Dave": name = input("Enter your name")
Iteration
223
What is casting? [1]
Converting one data type to another [1]
224
What is the python command to cast to a string? [1]
str() [1]
225
What is the python command to cast to an integer? [1]
int() [1]
226
What is the Python command to cast an ASCII number to its matching character? [1]
chr() [1]
227
What is the Python command to cast a character to it's matching ASCII number? [1]
ord() [1]
228
What is an integer?
A whole number e.g. 2
229
What is a character
A single letter, number or symbol e.g. A
230
What is a string
A sequence of characters, e.g. Hello
231
What is a real number
A number with a decimal e.g. 2.2
232
What are real numbers also known as?
floats / floating point numbers
233
What is a Boolean
True or False
234
What data type would be best suited to store a phone number?
String - if you use int you'll lost the 0 at the start.
235
What data type would be best suited to store the time in a 100m race?
Real number - you need the detail from the decimal
236
Name two ways to manipulate strings [2]
Concatenation - combining strings [1] Slicing - taking part of a string [1]
237
What would be the output of this code? name = "Dave" print (name[0:2])
"Da"
238
What is a record? [2]
A set of data [1] spanning multiple fields [1]
239
How do you declare an array in Python?
listName = []
240
What is a 2D array? [1]
An array that contains other arrays. [1]
241
How would you access the first item of the second array in a 2D Python array called data?
data [1][0]
242
How would you access the third item of an array called data in Python?
data[2]
243
How would you access the last item of an array called data in Python?
data[-1]
244
Write the code to open a file in Python
file = open("filename")
245
Write the code to read one line of a file in Python
file.readline()
246
Write the code to read a whole file in Python
file.read()
247
Write the code to close a file in Python
file.close()
248
Write the code to declare the function 'findPrice' with the parameters price and VAT.
def findPrice (price, VAT):
249
Write the Python to create an array called letters containing the letters a, b, c, d
letters = ['a','b','c','d']
250
Write the Python code to generate a random number between 1 and 100
import random # import the random library number = random.randint(1,100) #Generate a number between 1 - 100
251
State the two types of subroutines [2]
Functions - return a value Procedures - don't return a value
252
What is the difference between a local and global variables? [2]
Local variables are defined within a subroutine. They can only be accessed in that subroutine [1] Global variables are defined outside of a subroutine. They can be accessed anywhere in the code. [1]