1/133
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
A computer
Includes hardware and software, stores and process data
Hardware
The physical elements of the computer. Eg: Monitor, Speaker, Mouse, RAM, computer case
Software
Invisible instructions that control hardware. Eg: Word & Powerpoint
Bus
Subsystem that interconnects the computer components, found inside of the motherboard
Bus

Output devices
Sends data from a computer to another device or user, (audio video text graphics) Eg: Monitor (which displays text and graphics), speakers, printers.
Resolution and dot pitch
Determines the quality of the display
Input devices
Send data to a computer, Eg: keyboard and mice
CPU (central processing unit)
Brain of the computer, retrieves instructions from memory.
CPU speed
MHz=1 million pulses per second
Memory
stores data and program instructions
Saves ordered sequences of bytes (each byte=8bits)
Volatile, lost once power is off
Lost whenever new info replaces the old info
Storage devices
Permanently stored & nonvolatile Eg: Disk drives (hard & floppy), CD drives (CD-R, CD-RW) and tape drives (magnetic tape)
Programs
Software that has instructions for the computer. Are written using programming languages
Machine languages
Primitive instructions, binary code, difficult to read and modify by user. Native language. Eg: 10100110
Assembly language
Difficult to understand by the computer, needs an assembler to change (convert) the assembly code to machine code. Eg: ADD 2, 3, result
High level languages
Easy to understand, english-like. Needs an interpreter or compiler to convert this language to machine code. Eg: Area=5×5×3.1415
High level language examples
Python, C++, C#, Java, COBOL, Visual basic, Ada, Pascal
Statement
Instructions in high-level language
Source code/ program
A program in high-level language
Interpreter/compiler
Translates the high-level code to machine code
Interpreter
Reads one statement and then changes it to machine code (one by one)
Compiler
Translates the entire source code to machine code (all together)
Operating system (OS)
Program that manages and controls computer activities eg: windows 10, linux, macOS
Application program
Cannot run without an operating system. Eg: internet browser, word
General purpose
High level language used in google search, nasa projects, python is interpreted and needs an interpreter
Interpreted
Interpreted one statement at a time
Object oriented
Objects created by classes
Reuse-able software
It relies on the object oriented software, making it easier to use the code in more than one place.
Class
A type that defines the objects pf the same kind with properties and methods
open source program
Software released under a license that the copyright holder gives the rights to change, or study and then distribute to anyone. Eg: two types of python interpreters
Interactive mode
A quick way of running python code, used in python shell.
> > > means shell is ready to use
Results are returned directly after enter. Cannot be edited
Code tracing
Interprets the results of each code line, and keeps track of the effect of each code statement.
Statement
Action or sequence of actions. Eg: print(“Welcome to python”)
Programming style
Easy to read and understand. Python is case sensitive
Documentation
Body of explanatory remarks and comments
Comment
A programmer readable explanation that is ignored by the interpreter. Starts with #
Script mode
Script mode (normal mode) is written in a text file with the extension .py. Result is returned as a full file after being created and saved. Can be edited
Python
General purpose, interpreted, object oriented
Overflow error
Variable with too large of a value
Underflow error
Variable with too small of a value
String + string
Concatenation of strings
Number + number
Sum of numbers
String + number
Error (type error)
Syntax error
Error in code construction
Mistyped statement (Syntax)
Y=4
X=
Print(x)
Incorrect indentation (syntax)
Print(“hello”)
X=3
Print(x)
Incorrect parenthesis (syntax)
print(3+5
print(“hello”)
Punctuation (syntax)
print(“Hello).
Runtime error
Causes the program to terminate abnormally (abort) and detected by the interpreter
Input mistake (runtime)
Divided by zero:
x=0
print(10/x)
Entering a string value whilst the expected result is numbers:
area=input (“Enter area”)
A variable with an unidentified value:
x=4
print(y+x)
Calculation with non numeric values:
x=‘4’
y=3
print(x+y)
Logic error
Causes incorrect output (or unexpected results)
Direct value assignment
x=3
Assigning a value from an expression result
x=4+6
or
y=4
x=y+6
Assigning a value taken from the user through the keyboard
x=input(“enter the value”)
assign one value to multiple variables
a=b=k=3
assign multiple values to multiple variables in one line
a,b,c=4,3.5,”ahmed”
or a,b,c=input(“enter three variables”
Swap values between two variables
x=3
y=5
x,y=y,x
string
anything between ‘’
integer numbers (int)
whole numbers
Float numbers (float)
fractions
boolean
True/False
Operators precedence

import time time.time()
returns number of milliseconds since 1970
import math
returns math module functions
Current time

eval()
Converts a value to its original type
input()
Reads the value from the user via the keyboard
print()
Prints a value
int()
Converts a value to an integer
str()
converts a value into a string
bool()
converts a value into true(1) or false(0)
abs(x)
Returns absolute value
max(x1,x2,x3)
returns the largest value
min(x1,x2,x3)
returns the smallest value
pow(x,y)
x to the power of y
round(x)
rounds to the nearest whole number (integer result)
round(x,y)
rounds to a specific number of decimal places (float result)
math.pi
returns pi (3.14159)
math.e
returns value of 2.71828 (eulers number)
fabs(x)
returns absolute value in decimal/float form
ceil(x)
rounds up to the nearest integer
floor(x)
rounds x to the smallest integer
exp(x)
returns e to the power of x
log(x)
log(number) using base e
log(x,base)
Log x by base of base
sqrt(x)
square root of x
sin(x)
sin of x
asin(x)
sin-1 of x
cos(x)
cos of x
acos(x)
cos-1 of x
tan(x)
tan of x
degrees(x)
converts radians to degrees
radians(x)
converts degrees to radians
importance of degrees/radians functions
sin/cos/tan functions work in radians, so you have to convert them to degrees
bool(x)
converts number (integer) into true or false (boolean)
int(bool(x)) or int(boolean)
converts boolean into integer
Float division
one / with decimal placements
Integer division
two // no decimal placements
in the situation that one of the numbers has decimals the result will always be x.0 (eg 2.2//1 will be 1.0)
modulus or remainder
%
if first number is smaller than second number, the output will be the first number. If not, regular output.