Professional Documents
Culture Documents
Computer Science Test 1
Computer Science Test 1
Computer Science Test 1
CPU
● The CPU contains the basic arithmetic, logic, and control elements of a
computer required for processing data. ‘The computer’s brain is a popular
phrase’.
● The control unit (CU) is a CPU component that directs the operation of the
processor, and it decides what's allowed in the CPU and what isn't.
● An arithmetic logic unit(ALU) is a digital circuit that performs arithmetic and
bitwise operations on integer binary numbers. (performs arithmetic
calculations).
Memory
● Primary memory is computer memory that a processor accesses directly. For
example, it allows a processor to access running execution applications.
● Secondary memory is the various storage media on which a computer can
store data and programs. Unfortunately, secondary memory is quite large and
slow.
● Primary memory usually refers to Random Access Memory (RAM) and
registers. In contrast, secondary storage relates to hard disk drives, solid-
state drives, removable “USB” drives, CDs, and DVDs.
Buses
● Buses allow communication between the components in a computer.
● The purpose of an address bus is to identify the address of the location in the
primary memory. CPU -> RAM one-way.
● The data bus allows the data transfer to the CPU.
● Control bus - carries signals of the decision made by the CU to determine
what goes in and out.
Registers
● memory address register (MAR) - holds the address of the current instruction
that is to be fetched from memory.
● The Memory Data Register is the register of a computer's control unit that
contains the data to be stored.
● The program counter (PC) is a register that manages the instruction’s memory
address to be executed next.
● The current instruction register (CIR) is the part of a CPU's control unit that
holds the instruction currently being executed or decoded.
● In the CPU, the accumulator is a register in which ALU results are stored.
Variables
Loops:
● Iteration: a loop/a use of a loop that goes over something multiple times.
Programing construct:
Selection:
● If statements help us run a particular code only when a specific condition is
met.
● For example, if you want to print a message on the screen only when a
condition is true, you can use the if statement to achieve that.
Sequencing:
● Sequencing: executing values stored in a variable in order (line by line
execution of code)
● Sequences such as lists can include more than one value of data into one
variable, but “ [“ ”] ” is used instead of “ ( ) “, and commas should be used too
between each variable.
● Python uses 0 indexing, meaning it starts counting from 0.
● Lists can be updated like a normal variable could.
● A value can be overwritten in a list variable.
List properties:
● When the length function is used on a list, it returns the number/amount of
values in a list number of values instead of the characters. e.g.
Things = [“pencil” , “eraser”]
print(len(things)) → output is 2
● Dot notation: a way to call specific methods on specific objects.
● Lots of dot notation methods can be used on a list.
● .append is how we add items to our list, but they always get added to the end
of the list.
● .insert(): allows you to add specific items to the list in specific areas.
● .pop: removes the last item from the list.
● .remove: removes the first value from the list.
● .reverse(): reverses the order of the list in range (e.g. 0-3 → 3-0)
● .sort(): sorts the elements of an array (list) in place and outputs the sorted
array.
● .count(): says the number of times a specific value appears in a list.
Note
● Immediate access store: registers or primary memory.