Computer Science Notes:
29 September, 2015
Problem Solving:
1. Ability to formulate problems
2. Think creatively about solutions
3. Express a solution clearly and accurately
Machine code (hardware specific):
Very rare use
Machine code is the only language a computer can process directly without a previous
transformation.
Usually a binary stream. 0010010101000101
When programmers work with Machine code they usually do it in hexadecimal which is later
translates to binary.
Assembly language (hardware specific):
Uncommon use
Why use them?
● to make use of special hardware features
● to write more efficient code
● to write code that is more optimized and performs tasks more quickly
Example: Device drivers, BIOS, graphing calculator instructions, flight navigation systems etc…
Device Drivers:
A device driver is a program that controls a particular type of device that is attached to your
computer. There are device drivers for printers, displays, CD-ROM readers, diskette drives,
and so on. When you buy an operating system, many device drivers are built into the product.
BIOS:
BIOS (basic input/output system) is the program a personal computer’s microprocessor uses to
get the computer system started after you turn it on. It also manages data flow between the
computer’s operating system and attached devices such as the hard disk, video adapter,
keyboard, mouse and printer.
Assembler
● Translates low-level language program into machine code
● Assembled programs can be used without the Assembler
● Most programs are distributed already assembled.
High-Level Languages
, ● Easier to read and understand as the language used is closer to human language
● Faster to write programs
● Easier to debug at the development stage
● Easier to maintain once in use
● Many are portable and can be used on many different types of computers.
Compiler vs Interpreter
Compiler
● Translate a high-level language program into machine code
● An executable file of machine code is produced
● Compiled programs are used without compiler
● Each statement may require several machine code instructions.
Interpreter:
● Executes a high-level language program a statement at a time
● Interpreted language programs can not be used without the interpreter
● Each statement may require several machine code instructions.
High-level language vs Low-level language
High level Low level
● python - Microsoft macro assembler
● C, c++, C sharp
Computer program
● A list of specific instructions that enable a computer to perform a specific task.
● Can be written in a high-level or a low-level language (most written in high-level
languages)
Composition of a computer program
input = Get data from the keyboard, a file or some other device
output = Display data on the screen or send data to a file or other device
math = perform basic mathematical operations like addition and multiplication.
conditional execution = check for certain conditions and execute the appropriate code.
repetition = perform some action repeatedly, usually with some variation.
Debugging:
1. Syntax errors
Program syntax needs to be correct or it will not run.
Example: need to close parentheses if you open them
1. Runtime errors (exceptions).
Program will start running and crash. Example: division by 0
, 1. Semantic Errors
The program will run successfully but will not do what you wanted it to.
October 8, 2015
School = “FIS”
= —> Assigns a value to the variable.
FIS = “school” is different to school = “FIS”
Comments:
● It is important to add notes to your program code.
● Comments start with #
● Good variable names reduce the need to comment too much
November 19, 2015
Modulus operator %:
The modulus operator works on integers and yields the remainder when the first operand is
divided by the second.
operand = what we are operating on
Can be used to find the last digit(s) of a number.
Boolean expressions ==:
A boolean expression is an expression that is either true or false.
What does the == operator do? '==' is a question.
Example:
Can be used to find numbers, words and equations
, x!=y x is not equal to y
x >y x is greater than y
x<y x is smaller/less than y
x >= y x is greater than or equal to y
x <= y x is less than or equal to y
November 24, 2015
Logical operators
There are three logical operators: and, or and not.
OR = If one or more statements are true, then it is true.
AND = Both statements need to be true to make the statement true.
not(5>6)
not(6>=6)
(2>3) or (0<=1)
(2<3) and (0<=1)
(23%2!=0) and not (12**2%2 == 1)
(23%2 == 0) or not (12**2%2 == 1)
not(True) or not(False)
not(not(‘James' == ‘funny' or not(‘Natalie' == ‘Hadrian')))
not(not(True)) or not(not(False)) and not(False) —> True
November 26, 2015
Data Transmission
What are some examples of data transmission?
● Computer to printer
● CPU to RAM
● USB Memory Stick to Computer
● Server to Client
● Phone to phone through the telephone network
● Scanner to computer
When data is transmitted from one computer to another; they travel along some medium
(copper wire, optical fibre, as radio waves, infrared) in the form of bits. For example, when the
data is transmitted using wires they are transmitted in the form of voltage changes. The sender
will generate one voltage to represent 1 and a different voltage to represent 0.
Bandwidth
The range of frequencies that a medium can transmit is known as its bandwidth. The wider the
bandwidth, the more data can be transmitted. An optical fibre has a very high bandwidth so it
can transmit a very large amount of data. A normal telephone wire has a very low bandwidth so
it is not possible to transmit as much data.
A single optical fibre can carry over 3,000,000 full-duplex voice calls or 90,000 TV channels.
29 September, 2015
Problem Solving:
1. Ability to formulate problems
2. Think creatively about solutions
3. Express a solution clearly and accurately
Machine code (hardware specific):
Very rare use
Machine code is the only language a computer can process directly without a previous
transformation.
Usually a binary stream. 0010010101000101
When programmers work with Machine code they usually do it in hexadecimal which is later
translates to binary.
Assembly language (hardware specific):
Uncommon use
Why use them?
● to make use of special hardware features
● to write more efficient code
● to write code that is more optimized and performs tasks more quickly
Example: Device drivers, BIOS, graphing calculator instructions, flight navigation systems etc…
Device Drivers:
A device driver is a program that controls a particular type of device that is attached to your
computer. There are device drivers for printers, displays, CD-ROM readers, diskette drives,
and so on. When you buy an operating system, many device drivers are built into the product.
BIOS:
BIOS (basic input/output system) is the program a personal computer’s microprocessor uses to
get the computer system started after you turn it on. It also manages data flow between the
computer’s operating system and attached devices such as the hard disk, video adapter,
keyboard, mouse and printer.
Assembler
● Translates low-level language program into machine code
● Assembled programs can be used without the Assembler
● Most programs are distributed already assembled.
High-Level Languages
, ● Easier to read and understand as the language used is closer to human language
● Faster to write programs
● Easier to debug at the development stage
● Easier to maintain once in use
● Many are portable and can be used on many different types of computers.
Compiler vs Interpreter
Compiler
● Translate a high-level language program into machine code
● An executable file of machine code is produced
● Compiled programs are used without compiler
● Each statement may require several machine code instructions.
Interpreter:
● Executes a high-level language program a statement at a time
● Interpreted language programs can not be used without the interpreter
● Each statement may require several machine code instructions.
High-level language vs Low-level language
High level Low level
● python - Microsoft macro assembler
● C, c++, C sharp
Computer program
● A list of specific instructions that enable a computer to perform a specific task.
● Can be written in a high-level or a low-level language (most written in high-level
languages)
Composition of a computer program
input = Get data from the keyboard, a file or some other device
output = Display data on the screen or send data to a file or other device
math = perform basic mathematical operations like addition and multiplication.
conditional execution = check for certain conditions and execute the appropriate code.
repetition = perform some action repeatedly, usually with some variation.
Debugging:
1. Syntax errors
Program syntax needs to be correct or it will not run.
Example: need to close parentheses if you open them
1. Runtime errors (exceptions).
Program will start running and crash. Example: division by 0
, 1. Semantic Errors
The program will run successfully but will not do what you wanted it to.
October 8, 2015
School = “FIS”
= —> Assigns a value to the variable.
FIS = “school” is different to school = “FIS”
Comments:
● It is important to add notes to your program code.
● Comments start with #
● Good variable names reduce the need to comment too much
November 19, 2015
Modulus operator %:
The modulus operator works on integers and yields the remainder when the first operand is
divided by the second.
operand = what we are operating on
Can be used to find the last digit(s) of a number.
Boolean expressions ==:
A boolean expression is an expression that is either true or false.
What does the == operator do? '==' is a question.
Example:
Can be used to find numbers, words and equations
, x!=y x is not equal to y
x >y x is greater than y
x<y x is smaller/less than y
x >= y x is greater than or equal to y
x <= y x is less than or equal to y
November 24, 2015
Logical operators
There are three logical operators: and, or and not.
OR = If one or more statements are true, then it is true.
AND = Both statements need to be true to make the statement true.
not(5>6)
not(6>=6)
(2>3) or (0<=1)
(2<3) and (0<=1)
(23%2!=0) and not (12**2%2 == 1)
(23%2 == 0) or not (12**2%2 == 1)
not(True) or not(False)
not(not(‘James' == ‘funny' or not(‘Natalie' == ‘Hadrian')))
not(not(True)) or not(not(False)) and not(False) —> True
November 26, 2015
Data Transmission
What are some examples of data transmission?
● Computer to printer
● CPU to RAM
● USB Memory Stick to Computer
● Server to Client
● Phone to phone through the telephone network
● Scanner to computer
When data is transmitted from one computer to another; they travel along some medium
(copper wire, optical fibre, as radio waves, infrared) in the form of bits. For example, when the
data is transmitted using wires they are transmitted in the form of voltage changes. The sender
will generate one voltage to represent 1 and a different voltage to represent 0.
Bandwidth
The range of frequencies that a medium can transmit is known as its bandwidth. The wider the
bandwidth, the more data can be transmitted. An optical fibre has a very high bandwidth so it
can transmit a very large amount of data. A normal telephone wire has a very low bandwidth so
it is not possible to transmit as much data.
A single optical fibre can carry over 3,000,000 full-duplex voice calls or 90,000 TV channels.