Term1 Notes For Notebook - 033114
Term1 Notes For Notebook - 033114
Components of computer
A computer system comprises of 5 basic components:-
i) Input unit:- Responsible for taking input from the user.
ii) Output Unit:- Responsible for generating result for the users.
iii) CPU:- Responsible for processing the data and instructions.
iv) Primary memory:- internal volatile memory where data and instructions are stored
during the processing.
v) Secondary memory:- External storage devices which provide permanent memory to the
computer system.
Computer Organization:-
It refers to the logical structure of a computer describing how its components are
connected together.
CPU
ALU Registers
Control Memory
BUS
2) Output Unit:- This unit is formed by the output devices attached to the computer. The
output coming from the CPU is in the for m of electronic binary signals which needs
conversion in some form which can be easily understandable by human, so this
conversion is done by an Output devices. Some common output devices are monitors,
speakers, printers and so on.
3) CPU:- Central Processing Unit (CPU):- The CPU or processor is the unit which perform
most of the processing inside a computer. It processes all instructions received by
software running on the computer, and also by hardware components.
CPU is also known as Processor and consists of three units namely:-
i) Control unit ii) Arithmetic Logic Unit iii) Registers
3.2) ALU:- It is a digital circuit inside the processor that handles arithmetic and logical
operations by loading data from input registers(temporary memory space).
3.3) Registers:- Registers or processors are small unit of memory. The CPU uses registers
to temporarily hold some important processing-information during the processing time.
CPU may stores some part of data or memory address or some instructions in registers.
Memory Units
Smallest memory of the computer system is Bits i.e 0 or 1
B
i
t
s
B
yt
es
(8
bi
ts
)
Kil
o
Byt
es(
KB
)
(10
24
byt
es)
Me
ga
Byt
es
(M
B)
(10
24
KB)
Gi
ga
By
tes
(G
B)
(1
02
4
M
B)
Te
rra
By
tes
(T
B)
(1
02
4
GB
)
Pe
ta
By
tes
(P
B)
(1
02
4
TB
)
Ex
a
By
te
(E
B)
(1
02
4
PB
)
Ze
tta
By
te(
ZB
)
(1
02
4
EB
)
Yo
tta
By
te(
YB
)
(1
02
4
ZB
)
ROM:-
Performs read only operations
Stores the data permanently in memory.
It’s a non-volatile memory
ROM’s are used in applications where information never need to be altered.
1) PROM (Programmable ROM):- Also called OTP. In this type information is burnt
using special equipment called ROM Burner.
4) Flash EEPROM:- It is same as EEPROM but much faster than then EEPROM and
erase the full data not selected.
Cache Memory:-
The cache memory is a high speed memory available inside CPU in order to speed up
access to data and instructions stored in RAM. If the data is found in cache, CPU does not
access memory and hence the process becomes fast.
When data is found in cache, it is called cache hit and the effectiveness of cache
memory is judged by its hit rate.
Types of Software
A software or computer software essentially a type of programs which enable the users to
perform some particular tasks or usually used to operate the computer. A software plays a
key role between the user and the machine. In its absence none of the machine can
perform any task.
Software
System
Operating System
Language Processor
Application
Presentation
Database
Word processing
System Software:- It is a software which is used to manage the behavior of the computer
hardware to perform basic functionalities which are needed by the user. It acts as an
intermediator between the user and the hardware.
The system software can be further classified into two categories:-
1) Operating System:-
It’s a program which act as an interface between user and machine. An OS is an
important component of a computer which controls all other components of the
computer system.
There are various types of OS are available like single user OS, Multi User OS, Time
Sharing OS, Real Time OS, Multiprocessing OS, Distributed OS etc.
2) Language Processors:-
The software that translates the source code(Program-code written by the
programmer using any programming language) into an object code or machine code (
Code usually in machine language or binary code, that a computer can understand easily
and runon hardware).
ii) Inerpreter:- System software that translates and execute instructions written in
program line-by-line.
iii) Compiler:- System Software that translates and executes the whole instructions
written in computer program in a single go.
Application Software:- These software are designed to perform some specific tasks only
like writing, listening, music etc. For all these requirements user needs a software for each
type and that specific software is designed for that specific purpose only which are called
Application software.
Chapter 2
Two examples of each type of conversions.
Octal and hexadecimal value table
Chapter 3
Boolean Logic
Logical Operations:-
1) Logical Operators:- Truth table is a table which represents all the possible values of logical
variables/statements along with all the possible results of the given combination of values.
Basically there are three logical operators are there:-
OR Operator:- This operator represents Boolean Addition and the symbol used is (+) plus. Thus
X+Y read as X OR Y. For OR the possible input and output conditions are:-
X Y X.Y
0+0=0
0 0 0
0+1=1
0 1 0
1+0=1
1 0 0
1+1=1
1 1 1
In OR operator result will get True if any of the given condition becomes True, the result will only
be False if all the conditions are False.
NOT operator:- This operator operates on single value and operation performed by NOT is called
Complementation and the symbol used is bar. Thus X means Complement of X
0=1 X X
1=0 0 1
1 0
3) NOT gate(Inverter)
For a single input NOT gate, the output Q is PNLY true when the input is NOT true, the
output is the inverse or complement of the input giving the Boolean Expression:
(Q = NOT A).
4) input NAND (Not AND) Gate
For a 2-input NAND gate, the output Q is NOT true if BOTH input A and input B are true,
giving the Boolean Expression of (Q = not(A AND B)).
De-Morgans Theorem
De-Morgan has suggested two theorems which are extremely useful in Boolean Algebra.
Theorem 1
A.B= A+ B
NAND= Bubbled OR
Chapter 5
Problem solving
Definition of flowchart with all its symbols, algorithm, problem solving cycle
with its sequence.
Two examples of flowchart and algorithm have to write given in your book
Chapter 6
Getting Started with Python
Python is a high level, interpreted, interactive and Object Oriented programming language, which
is developed by Guido van Rossum during the year 1985-1990. It has fewer syntactical
constructions than other languages.
Python is Interpreted bcoz it get processed at runtime by the interpreter, means programmer
don’t need to compile the program before execution.
Python is Interactive bcoz user can directly interact with the python prompt to write their
programs.
Python is Object Oriented bcoz it supports that kind of programming technique in which
encapsulate code within objects.
Modes in Python
Python supports two different modes for writing our program:-
Interactive mode:-
This mode is also known as REPL which provides us a quick way to write our program in
a single line. The code will get executed via Python Shell which comes with Python installation.
To work with this mode, we need to open Python IDE. The >>> indicates that the Python shell
is ready to execute and send command to the Interpreter.
Script Mode:-
In this mode programmer have to write code in a text file and then save it with the .py
extension. After writing the complete code, for its execution we need to click on “RUN” then
“RUN MODULE” or simply press F5. We can execute our program from the terminal of the OS.
For this we have to use a keyword python followed by the name of the file with .py extension.
1) In script mode, a file must be created and saved before its execution.
In Interactive mode the result is returned immediately whenever we press Enter key.
2) In Script mode, user can directly edit the command or code given which is not
possible in Interactive mode.
Chapter 7
Identifiers:- Identifiers are the fundamental building blocks of a program and are used as the
general terminology for the names given to different parts of the program by a variables, objects,
classes, functions etc.
In python an identifiers starts with a letter A-Z or a-z an underscore( _ ) followed by zero or
more letters, digits (0 to 9)
Python does not allow any kind of special characters like & % $ with an identifiers.
Python is a case sensitive programming language.
Literals/value:- Literals (referred as Constant values) are data items that have a fixed value.
Python allows several kinds of literals:-
ii) Numeric Literals:- This literal is capable to hold any type of numeric values like integers,
decimals, complex values.
iii) Boolean Literals:- This literal is used to represent one of the two Boolean values i.e True or
False. This literal can either have value as True or False.
ii) Multiline String:- String across multiple lines called Multiline String. Multiline strings can be
created in two ways:-
a) By adding a backslash at the end of a normal single quote /double quote string
Ex:- x=”hello\
world\
i am\
python”
b) By typing the text in triple quotation marks
Ex:- x=’’’hello
World’’’
Operators:- Operators are the tokens that triggers some computations when applied to variables
and other objects (i.e operands) in an expression. Python supports:-
ii) Binary Operator:- These operators require two operands. All the Arithmetic, Bitwise, Shift,
Identity, Relational, Logical, Assignment and Membership Operators are Binary operators.
Arithmatic Operators:-
+ Addition
− Subtraction
* Product
% Remainder/
Modulus
** Exponent
/ Division
// Floor Division
IdentityOperators:-
is is the identity
same
is Is the identity not
not same
Relational Operators:-
< Less than
> Greater than
<= Less than equal
to
>= Greater than
equal to
== Equal to
!= Not Equal to
Logical Operators:-
AND Logical AND
OR Logical OR
Assignment Operators:-
= Assignment
/= Assign Quotient
+= Assign sum
*= Assign product
%= Assign remainder
−= Assign difference
**= Assign Exponent
//= Assign Floor
division
Membership Operators:-
in Whether variable in
sequence
not Whether variable not in
in sequence
Chapter 8
Data Handling
Data Types
Python Data Types
Integer Strings
Complex
List
Number
Float Tuple
Numbers:-stores numeric values like integer, float and complex values. Python supports three
types of numeric data:-
1) Int:- for integer values like ( -20,30, -300 etc). Python has no restrictions regarding the
Length.
2) Float:- used for decimal values like 102.5, 2.7 etc. It is accurate upto 15 decimal places
3) Complex:- contains an ordered pair like x+iy, where x and y represent real and imaginary parts
respectively. Ex. 2.3j, 2+3j, 2.5 + 4,5j
Dictionary:- It is an unordered set of a key-value pair of items where each key stores a specific
value. The items in the dictionary are separated with the comman(,) and always enclosed in a
curly braces ({} )
Ex d = {1:’a’,2:’b’,3:’c’, 4:’d’ }
Boolean:- It provides two built-in values i.e True and False. This data type is denoted by the
keyword bool .True values are represented by 1 or ‘T’ and False value by 0 or ‘F’
Set:- It is unordered collection of the data type which can be modify also after the creation and
has unique elements. In Set, order of the element is undefined, may return the changed sequence
of the elements. It is created by the keyword set()
Ex:- set={‘a’,1,2,’b’}
Sequence Type:-
1) String :- Set of characters called String. We can create String by simply enclosing the
characters in single quote (‘ ‘) or, double quote (“ “) or triple quote (‘ “ “ ‘) Python treats single
and double quote equally. String creation is as simple assigning values to a variable.
x=”Hello world”
x=’hello world’
Some special charactes supported by the string data type are:-
1) + (Concateation)The process of adding two or more string together.
Ex: “hello” + “ Python” we get hello python
ello Wo
1) Math module:- To use this module firstly we need to import this module in our code using
import.math
Then after importing the module we are able to access the functions available in the math module using
math.<function_name>
2) Random Module:- This module generate random numbers, i.e. a number generated by chance. To
use this module user must have to import a module via
Import random
Three most common random number generator functions in random module are:-
i) random() :- returns the floating point number in the range of 0.0 to 1.0.
ii) randint(a,b):- returns floating point number from in between the given two integer values
i.e a and b
iii) randrange(<start>,<stop>,<step>):-
returns number in between start..stop with step value .
ii) random.randrange(<startvalue>, <stopvalue>):- generate random number from in between the given
<startvalue> and <stopvalue>
>>>random.randrange(10,20)
18
>>>random.randrange(10,40,6)
22
3) Statistics module:- This module of Python provides many statistical functions like mean(), median(),
mode() etc. To use these function user needs to import a file called
Import statistics
ii) statistics.median(<seq>):- return the middle value from the given set values.
iii) statistics.mode(<seq>):- return the most often repeated value from the given sequence.
Ex:-
>>>import statistics
>>> seq=[3,4,2,8,5,4,5,9,5,2]
>>>statistics.mean(seq)
12.5
>>>statistics.median(seq)
5
>>>statistics.mode(seq)
5
Concept of Lvalues and R Values, Error and its types also have to write
Chapter 9
Flow of Control
Statement:- Statements are the instructions given to the computer to perform any kind of action. It
forms the smallest executable unit within the python program.
Python supports three types of statements:-
1) Empty statement:- The statement which does nothing is called empty statement. In python the
empty statement is pass statement. This pass statement moves to the next statement in the flow of
control. This pass statement is useful for that instances when syntax of the language requires the
presence of the statement but where the logic of the program does not.
2) Simple statement:- Any single line executable statement is a simple statement in python. For ex:-
print(x), x=5 etc
Example:- if 2<100:
Print(“yes”)
2) if-else… Statement:-
Along with the if statement the else condition can be optionally used to define an
alternate block of statements to be executed, if the given Boolean expression return false i.e if
expression returns true value it carries out all the instruction indented inside the ‘if’ and if the
condition become false it carries out the instruction indented in side the ‘else’.
Syntax:- if [boolean expression]:
Statement 1
Else :
Statement 2
Example:- if 2>3:
Print (“2 is greater”)
Else :
Print(“3 is greater”)
3) elif statement:- This condition is used to include multiple conditional expressions between
if and else statement because sometime we need to check another condition the one condition
returns false and so-on.
While Statement:-
A while loop is a conditional loop that will repeat the instructions within itself as
long as the condition remains True. This loop is also known as Control loop statement
because in this loop condition gets verified initially, then the execution of the statements is
determined based on the condition result.
Syntax:- while[Boolean expression]:
Statement1
Statement 2
.
.
Statement n
Output:- num =1
num =2
num =3
num =4
num =5
For Statement:-
In python, the For loop is used with sequence types like list, tuple and set.The for
statement is used to repeat the execution of a set of statements for every elements of a
sequence. In this loop there is no such condition to check the loop initially before the
execution begins.
Output:- 10
20
30
40
Output:- 1
2
3
4
5
Job is DONE
Jump statements in python are used to alter the flow of a loop like you want to skip a
part of a loop or terminate a loop. Python offers two jump statements to be used
within loops , break and continue statements
Break Statement:-
Break statement is used to exit from the iterative statements (loops) such as for,
while loop. Use of this statement terminates the execution of loop immediately, and then
program execution will jump to the next statements.
Syntax:- while condition1:
Statement 1
Statement 2
If condition2:
Break
Continue Statement:-
This statement is used to continue the loop execution i.e to get back to the top of
the iterative statements (loops) like for, while. US of this statement stops the further
statement execution of loop immediately.
Chapter 10
String Manipulation
Strings:- Any sequence of characters is called String. Strings are enclosed in single (‘ ‘) or
double (“ “) or Triple (“ ‘ ‘ “) quote. Each and every character has a unique index values.
The indexes of any string begin with the index value 0 to length-1
Basic String Operators:- The two basic String operators are + and * which is used for
Concatenation and Replication rather than addition and multiplication.
i) String Concatenation Operator (+):- This operator is used to create new String by joining
two or more operand strings. Ex:- “Tea”+”Pot” gives TeaPot
ii) String Replication Operator (*):- This operator is used to create multiple copies of a
given string. This operator is used with one string with one integer operand. For ex:-
3*”go!” give go!go!go!, “go!”*4 gives go!go!go!go!
For replication string both operand values cannot be of String type.
Membership Operator:- There are two membership operators for strings, these are in an
not in operators.
in – this operator return True if a character or a substring exists in the given string,
else return False
not in – this operator return True if a character or a substring does not exists in the
given string else return
False.
Ex:-
“a” in India True
“dia” in “India” True
Ordinal Function ( ord() ):-This function takes single value as an input and as a result
return its UNICODE value.
Character Function(chr()):- This function works just opposite to ord() function, in which it
takes value as an input and return character corresponding to that value.
Syntax:- chr(<int>)
Ex:- >>>chr(65)
A
String Functions
1) capitalize():- This function convert first character of a sting to uppercase and lowercase all
other characters, if any.
Syntax:- String.capitalize()
2) count():- This function returns the number of occurrences of a substring in the given string
String i.e this method searches the substring in the given string and returns how many times the
substring is present in it.
It also takes optional parameters “start” and ‘end” to specify the starting and ending position
in the string respectively.
Syntax: string.count(substring)
3) find():- It returns the index of the first occurrence of the substring (if found). If not found return
-1.
Ex:- ” Computer”.find(‘w’)
Output:- -1
” Computer”.find(‘o’)
Output:- 1
4) index():- It returns the index of a substring inside the string(if found). If the substring is not
found, it raise an exception. It is similar to find but the only difference is that find return -1 in case
of substring not exists where as index throw an exception.
Output:- Error
” Computer”.find(‘o’)
Output:- 1
5) isalnum():- This method returns true if all the characters in the string are alphanumeric( either
alphabets or numbers). If not, it return false
Syntax:- string.isalnum()
6) isalpha():- returns True if all characters in the string are only alphabets else return False.
Syntax:- string.isalpha()
Ex:- >>>”m442342onika”.isalpha()
>>>False
>>>”Bill Gates”.isalph()
>>>False
>>>”AmitabhBacchan”.isalpha()
>>>True
6) isdigit():- returns True if all characters in the string are only digits else return False.
Syntax:- string.isdigit()
7) islower():- returns True if all characters in the string are lower case alphabets if it contains at
least one uppercase alphabet it return False.
This function doesn’t take any parameters.
Syntax:- string.islower()
8) isupper():- returns True if all characters in the string are upper case alphabets if it contains at least one
Lowercase alphabet it return False.
This function doesn’t take any parameters.
Syntax:- string.isupper()
9) lstrip():- It returns a copy of the string with leading characters removed (based on the argument
passed). This lstrip() function removes the characters from the left based on the argument (a string
specifying the set of characters to be removed)
10) strip():- This method returns a copy of the string by removing both the leading and the trailing
characters (based on the string argument passed). When the characters of the string in the left
mismatches with all the characters in the chars argument, it stops removing the leading characters
and vice versa.
Syntax:- string.strip([chars])
11) Replace():- This method returns a copy of the string where all occurances of a substring is
replaced with another substring. The syntax of replace() is:-
str.replace(old, new)