You are on page 1of 26

UNIT I ALGORITHMIC PROBLEM SOLVING

Algorithms, building blocks of algorithms (statements, state, control flow, functions), notation
(pseudo code, flow chart, programming language), algorithmic problem solving, simple
strategies for developing algorithms (iteration, recursion). Illustrative problems: find minimum
in a list, insert a card in a list of sorted cards, guess an integer number in a range, Towers of
Hanoi
UNIT II DATA, EXPRESSIONS, STATEMENTS
Python interpreter and interactive mode; values and types: int, float, boolean, string, and list;
variables, expressions, statements, tuple assignment, precedence of operators, comments;
modules and functions, function definition and use, flow of execution, parameters and
arguments; Illustrative programs: exchange the values of two variables, circulate the values of n
variables, distance between two points.
UNIT III CONTROL FLOW, FUNCTIONS
Conditionals: Boolean values and operators, conditional (if), alternative (if-else), chained
conditional (if-elif-else); Iteration: state, while, for, break, continue, pass; Fruitful functions:
return values, parameters, local and global scope, function composition, recursion; Strings:
string slices, immutability, string functions and methods, string module; Lists as arrays.
Illustrative programs: square root, gcd, exponentiation, sum an array of numbers, linear search,
binary search.

UNIT IV LISTS, TUPLES, DICTIONARIES


Lists: list operations, list slices, list methods, list loop, mutability, aliasing, cloning lists, list
parameters; Tuples: tuple assignment, tuple as return value; Dictionaries: operations and
methods; advanced list processing - list comprehension; Illustrative programs: selection sort,
insertion sort, mergesort, histogram.
UNIT V FILES, MODULES, PACKAGES
Files and exception: text files, reading and writing files, format operator; command line
arguments, errors and exceptions, handling exceptions, modules, packages; Illustrative
programs: word count, copy file.
Problem solving is the act of defining a problem; determining the cause of the problem;
identifying, prioritizing, and selecting alternatives for a solution; and implementing a solution
Programming is the art and science of translating a set of ideas into a program - a list of
instructions a computer can follow.
Area of a circle can simply be evaluated using following formula.
Area = pi * r2 where r is radius of circle
# Python program to find Area of a circle

def findArea(r):
PI = 3.142
return PI * (r*r);

# Driver method
print("Area is %.6f" % findArea(5));
Mainly computer system
consists of three parts, that
are central processing unit
(CPU), Input Devices, and
Output Devices. The Central
Processing Unit (CPU) is
divided into two parts
again: arithmetic logic unit
(ALU) and the control unit
(CU). The set of instruction
is in the form of raw data.
The computer system is nothing without the Central processing Unit so, it is also known as the
brain or heat of computer. The CPU is an electronic hardware device which can perform
different types of operations such as arithmetic and logical operation.
The CPU contains two parts:
Arithmetic logic unit
Control unit.
Control Unit
Controls all the activities or operations which are performed inside the computer system.
It receives instructions or information directly from the main memory of the computer.
When the control unit receives an instruction set or information, it converts the
instruction set to control signals then; these signals are sent to the central processor for
further processing. The control unit understands which operation to execute, accurately,
and in which order.
Arithmetic and Logical Unit
The arithmetic and logical unit is the combinational digital electronic circuit that can
perform arithmetic operations on integer binary numbers.It presents the arithmetic and
logical operation. The outputs of ALU will change asynchronously in response to the
input. The basic arithmetic and bitwise logic functions are supported by ALU.
The information or set of guidelines are stored in the storage unit of the
computer system.
The storage unit provides the space to store the data or instruction of
processed data.
 The information or data is saved or hold in computer memory or storage
device.
The data storage is the core function and fundamental of the computer
components.  
A memory is just like a human brain. It is used to store data and instructions.
Computer memory is the storage space in the computer, where data is to be
processed and instructions required for processing are stored.
The memory is divided into large number of small parts called cells.
Each location or cell has a unique address, which varies from zero to memory
size minus one.
For example, if the computer has 64k words, then this memory unit has 64 *
1024 = 65536 memory locations. The address of these locations varies from 0 to
65535.
Memory is primarily of three types −
Cache Memory
Primary Memory/Main Memory
Secondary Memory

Cache Memory
Cache memory is a very high speed semiconductor memory
which can speed up the CPU.
It acts as a buffer between the CPU and the main memory.
It is used to hold those parts of data and program which are
most frequently used by the CPU.
The parts of data and programs are transferred from the disk
to cache memory by the operating system, from where the CPU
can access them.
Primary Memory (Main Memory)
Primary memory holds only those data and instructions
on which the computer is currently working.
 It has a limited capacity and data is lost when power is
switched off. It is generally made up of semiconductor
device.
These memories are not as fast as registers. The data and
instruction required to be processed resides in the main
memory.
It is divided into two subcategories RAM and ROM.
Secondary Memory
This type of memory is also known as
external memory or non-volatile.
It is slower than the main memory.
These are used for storing data/information
permanently. CPU directly does not access
these memories, instead they are accessed via
input-output routines.
The contents of secondary memories are
first transferred to the main memory, and then
the CPU can access it.
For example, disk, CD-ROM, DVD, etc.
A memory address is a reference to a specific memory location used at various levels
by software and hardware.
Memory addresses are fixed-length sequences of digits conventionally displayed and
manipulated as unsigned integers.
Such numerical semantic bases itself upon features of CPU (such as the instruction
pointer and incremental address registers), as well upon use of the memory like an array
endorsed by various programming languages.
Physical addresses
A digital computer's main memory consists of many memory locations. Each memory
location has a physical address which is a code. The CPU (or other device) can use
the code to access the corresponding memory location.

Generally only system software, i.e. the BIOS, operating systems, and some
specialized utility programs (e.g., memory testers), address physical memory using
machine code operands or processor registers, instructing the CPU to direct a hardware
device, called the memory controller, to use the memory bus or system bus, or separate
control, address and data busses, to execute the program's commands.

The memory controllers' bus consists of a number of parallel lines, each represented
by a binary digit (bit). The width of the bus, and thus the number of addressable storage
units, and the number of bits in each unit, varies among computers.

You might also like