Basic of COMPUTER SCIENCE Presented by Shubham Shewale.pdf
1. Page 1 of 60
"Basic of computer science”
by Shubham Shewale
Presented By:
Shubham Shewale
B.E. (CSE)
M.Tech (cse)
Computer Teacher, at Government Sec
Ashram School Tulshi, Mahur
2. Page 2 of 60
"Basic of computer science”
by Shubham Shewale
About Computer:-
Defination:-
―Computer is an electronic device that
manipulates data, data is nothing but any kind of
information.‖
Invention of Computer:-
The first computer was invented by
Charles Babbage in 1822.But was not built until 1991.
Initially, The structure of computer was like, weights 4535.92kg
(4.5 tons), measures 2.1 m, 3.4m, 0.5m (6’11‖ x 11’2‖ x 1’8‖) and
has 8,000 parts.
So as the time passed, there is lots of changes and development
occurred in the structure and functions of Computer.
Example:-
For example we (human beings) store some information in our
mind and as per our need we use it for any purpose, there may be
some information get stored in our temporary brain and some
information get saved in permanently. And as per our need we use
anytime when we need it.
Similarly Computer also work like our brain, he also
store some data in his temporary storage memory (RAM) and store
some data in Permanent Storage memory (ROM). And work on it as
per the user gives the command to him.
But how it differs from Human Brain??? If human brain
can solve those problems then why Computer was
invented???
3. Page 3 of 60
"Basic of computer science”
by Shubham Shewale
Characteristics of Computer:-
1) Speed:-
A computer works with much higher speed and accuracy
compared to humans while performing mathematical calculations.
Computers can process millions of instructions per second. The
time taken by computers for their operations is microseconds and
nanoseconds.
2) Accuracy:-
Computers perform calculations with 100% accuracy.
Errors may occur due to data inconsistency or inaccuracy.
3) Diligence:-
A computer can perform millions of tasks or calculations
with the same consistency and accuracy. It doesn’t feel any fatigue
or lack of concentration. Its memory also makes it superior to that
of human beings.
4) Versatility:-
Versatility refers to the capability of a computer to
perform different kinds of works with same accuracy and efficiency.
5) Reliability:-
A computer is reliable as it gives consistent result for
similar set of data i.e., if we give same set of input any number of
times, we will get the same result.
6) Automation:-
Computer performs all the tasks automatically i.e. it
performs tasks without manual intervention.
7) Memory:-
A computer has built-in memory called primary memory
where it stores data. Secondary storage are removable devices
such as CDs, pen drives, etc., which are also used to store data.
4. Page 4 of 60
"Basic of computer science”
by Shubham Shewale
Main Components of Computer:-
Fig: - Block Diagram of Computer
Basically Computer divided in three parts, they are: Input devices,
CPU and Output Devices.
1) Input Devices:-
Any equipment that used to provide data and control signals to CPU.
Keyboard, Mouse, scanners those are input devices.
Example: for example I have pressed a numeric key 5 from the
keyboard that’s mean I have given some input to the CPU.
2) CPU:-
CPU stands for - Central Processing Unit, Is also called as brain of the
computer.
The CPU is the primary component of the computer that’s processes
the instructions.
CPU is also divided in three parts, such as: Control Unit, Arithmetic
and Logical Unit and Memory Unit.
1) Control Unit:-
The control unit (CU) is a component of a computer's central
processing unit (CPU) that directs the operation of the processor. It
tells the computer's memory, arithmetic logic unit and input and
output devices how to respond to the instructions that have been
sent to the processor.
5. Page 5 of 60
"Basic of computer science”
by Shubham Shewale
2) Arithmetic and Logical Unit:-
All the arithmetic operations such as Addition, subtraction,
multiplication and division And all the Logical operations such as
comparison like greater than, smaller than, AND, OR operations
occurs in ALU,
3) Memory Unit:-
Memory unit is the amount of data that can be stored in the
storage unit. This storage capacity is expressed in terms of
Bytes.
3) Output Devices:-
An output device is a piece of computer hardware that receives
data from a computer and then translates that data into another
form. That form may be audio, visual, textual, or hard copy such
as a printed document.
Monitor, Printer, etc. are the output devices.
Example:- for example I have entered 10 from the keyboard
now I can see that on the Monitor i.e. I am getting the output
through output device Monitor.
6. Page 6 of 60
"Basic of computer science”
by Shubham Shewale
Generations of Computers:-
Basically, there are five generations of computers, are as follows:
1. FIRST GENERATION
Introduction:
1. 1946-1959 is the period of first generation computer.
2. J.P.Eckert and J.W.Mauchy invented the first successful
electronic computer called ENIAC, ENIAC stands for
―Electronic Numeric Integrated And Calculator‖.
Few Examples are:
1. ENIAC
2. EDVAC
3. UNIVAC
4. IBM-701
5. IBM-650
Advantages:
1. It made use of vacuum tubes which are the only electronic
component available during those days.
2. These computers could calculate in milliseconds.
Disadvantages:
1. These were very big in size, weight was about 30 tones.
2. These computers were based on vacuum tubes.
3. These computers were very costly.
4. It could store only a small amount of information due to the
presence of magnetic drums.
5. As the invention of first generation computers involves
vacuum tubes, so another disadvantage of these computers
was, vacuum tubes require a large cooling system.
6. Very less work efficiency.
7. Limited programming capabilities and punch cards were used
to take inputs.
8. Large amount of energy consumption.
9. Not reliable and constant maintenance is required.
2. SECOND GENERATION
Introduction:
1. 1959-1965 is the period of second-generation computer.
7. Page 7 of 60
"Basic of computer science”
by Shubham Shewale
2. Second generation computers were based on Transistor
instead of vacuum tubes.
Few Examples are:
1. Honeywell 400
2. IBM 7094
3. CDC 1604
4. CDC 3600
5. UNIVAC 1108
Advantages:
1. Due to the presence of transistors instead of vacuum tubes,
the size of electron component decreased. This resulted in
reducing the size of a computer as compared to first
generation computers.
2. Less energy and not produce as much heat as the first
generation.
3. Assembly language and punch cards were used for input.
4. Low cost than first generation computers.
5. Better speed, calculate data in microseconds.
6. Better portability as compared to first generation
Disadvantages:
1. A cooling system was required.
2. Constant maintenance was required.
3. Only used for specific purposes.
3. THIRD GENERATION
Introduction:
1. 1965-1971 is the period of third generation computer.
2. These computers were based on Integrated circuits.
3. IC was invented by Robert Noyce and Jack Kilby In 1958-
1959.
4. IC was a single component containing number of transistors.
Few Examples are:
1. PDP-8
2. PDP-11
3. ICL 2900
4. IBM 360
5. IBM 370
Advantages:
8. Page 8 of 60
"Basic of computer science”
by Shubham Shewale
1. These computers were cheaper as compared to second-
generation computers.
2. They were fast and reliable.
3. Use of IC in the computer provides the small size of the
computer.
4. IC not only reduces the size of the computer but it also
improves the performance of the computer as compared to
previous computers.
5. This generation of computers has big storage capacity.
6. Instead of punch cards, mouse and keyboard are used for
input.
7. They used an operating system for better resource
management and used the concept of time-sharing and
multiple programming.
8. These computers reduce the computational time from
microseconds to nanoseconds.
Disadvantages:
1. IC chips are difficult to maintain.
2. The highly sophisticated technology required for the
manufacturing of IC chips.
3. Air conditioning is required.
4. FOURTH GENERATION
Introduction:
1. 1971-1980 is the period of fourth generation computer.
2. This technology is based on Microprocessor.
3. A microprocessor is used in a computer for any logical and
arithmetic function to be performed in any program.
4. Graphics User Interface (GUI) technology was exploited to
offer more comfort to users.
Few Examples are:
1. IBM 4341
2. DEC 10
3. STAR 1000
4. PUP 11
Advantages:
1. Fastest in computation and size get reduced as compared to
the previous generation of computer.
2. Heat generated is negligible.
9. Page 9 of 60
"Basic of computer science”
by Shubham Shewale
3. Small in size as compared to previous generation computers.
4. Less maintenance is required.
5. All types of high-level language can be used in this type of
computers.
Disadvantages:
1. The Microprocessor design and fabrication are very complex.
2. Air conditioning is required in many cases due to the presence
of ICs.
3. Advance technology is required to make the ICs.
5. FIFTH GENERATION
Introduction:
1. The period of the fifth generation in 1980-onwards.
2. This generation is based on artificial intelligence.
3. The aim of the fifth generation is to make a device which
could respond to natural language input and are capable of
learning and self-organization.
4. This generation is based on ULSI(Ultra Large Scale
Integration) technology resulting in the production of
microprocessor chips having ten million electronic component.
Few Examples are:
1. Desktop
2. Laptop
3. NoteBook
4. UltraBook
5. Chromebook
Advantages:
1. It is more reliable and works faster.
2. It is available in different sizes and unique features.
3. It provides computers with more user-friendly interfaces with
multimedia features.
Disadvantages:
1. They need very low-level languages.
2. They may make the human brains dull and doomed.
10. Page 10 of 60
"Basic of computer science”
by Shubham Shewale
Hardware and Software:-
Hardware:-
Any component of computer that we can touch and feel is
Hardware.
Software:-
Software is a set of instructions that performs any task is called as
program. It is component of computer which cannot touch or feel is
software.
Software can be categorized into two types −
System software:-
System software operates directly on hardware devices of computer. It
provides a platform to run an application. It provides and supports user
functionality. Examples of system software include operating systems
such as Windows, Linux, Unix, etc.
Application software:-
Application software is designed for benefit of users to perform one or
more tasks. Examples of application software include Microsoft Word,
Excel, PowerPoint, Oracle, etc.
11. Page 11 of 60
"Basic of computer science”
by Shubham Shewale
Input and Output devices:-
Input Devices:-
Any equipment that used to provide data and control signals to CPU.
Keyboard, Mouse, scanners those are input devices.
Example: - For example I have pressed a numeric key 5 from the
keyboard that’s mean I have given some input to the CPU.
Examples of Input devices:
1) Keyboard:-
Keyboard is the most common and very popular input device which
helps to input data to the computer.
Keyboards are of two sizes 84 keys or 101/102 keys, but now
keyboards with 104 keys or 108 keys are also available for
Windows and Internet.
2) Mouse:-
Mouse is the most popular pointing device. It is a very famous cursor-
control device having a small palm size box with a round ball at its base,
which senses the movement of the mouse and sends corresponding
signals to the CPU when the mouse buttons are pressed.
Generally, it has two buttons called the left and the right button and a
wheel is present between the buttons. A mouse can be used to control
the position of the cursor on the screen, but it cannot be used to enter
text into the computer.
3) Scanners:-
Scanner is an input device, which works more like a photocopy machine.
It is used when some information is available on paper and it is to be
transferred to the hard disk of the computer for further manipulation.
Scanner captures images from the source which are then converted into
a digital form that can be stored on the disk. These images can be edited
before they are printed.
12. Page 12 of 60
"Basic of computer science”
by Shubham Shewale
4) Joystick:-
Joystick is also a pointing device, which is used to move the cursor
position on a monitor screen. It is a stick having a spherical ball at its
both lower and upper ends. The lower spherical ball moves in a socket.
The joystick can be moved in all four directions.
The function of the joystick is similar to that of a mouse. It is mainly
used in Computer Aided Designing (CAD) and playing computer games.
5) Light Pen:-
Light pen is a pointing device similar to a pen. It is used to select a
displayed menu item or draw pictures on the monitor screen. It consists
of a photocell and an optical system placed in a small tube.
When the tip of a light pen is moved over the monitor screen and the
pen button is pressed, its photocell sensing element detects the screen
location and sends the corresponding signal to the CPU.
6) Track Ball:-
Track ball is an input device that is mostly used in notebook or laptop
computer, instead of a mouse. This is a ball which is half inserted and by
moving fingers on the ball, the pointer can be moved.
Since the whole device is not moved, a track ball requires less space than
a mouse. A track ball comes in various shapes like a ball, a button, or a
square.
13. Page 13 of 60
"Basic of computer science”
by Shubham Shewale
Output Devices:-
An output device is a piece of computer hardware that receives
data from a computer and then translates that data into another
form. That form may be audio, visual, textual, or hard copy such
as a printed document.
Monitor, Printer, etc. are the output devices.
Example:- for example I have entered 10 from the keyboard
now I can see that on the Monitor i.e. I am getting the output
through output device Monitor.
Examples of Output Devices:-
1) Monitor:-
Monitors, commonly called as Visual Display Unit (VDU), are the main
output device of a computer. It forms images from tiny dots, called
pixels that are arranged in a rectangular form. The sharpness of the
image depends upon the number of pixels.
2) Printers:-
Printer is an output device, which is used to print information on paper.
3) Projectors:-
A projector is an output device that projects an image onto a large
surface, such as a white screen or wall. It may be used an alternative to
a monitor or television when showing video or images to a large group of
people.
14. Page 14 of 60
"Basic of computer science”
by Shubham Shewale
About CPU:-
CPU stands for - Central Processing Unit, Is also called as brain
of the computer.
The CPU is the primary component of the computer that’s works
on the instructions given by the user.
CPU is also divided in three parts, such as: Control Unit,
Arithmetic and Logical Unit and Memory Unit.
1) Control Unit:-
The control unit (CU) is a component of a computer's central
processing unit (CPU) that directs the operation of the processor. It tells
the computer's memory, arithmetic logic unit and input and output
devices how to respond to the instructions that have been sent to the
processor.
This unit controls the operations of all parts of the computer but does not
carry out any actual data processing operations.
Functions of this unit are −
It is responsible for controlling the transfer of data and instructions
among other units of a computer.
It manages and coordinates all the units of the computer.
It obtains the instructions from the memory, interprets them, and
directs the operation of the computer.
It communicates with Input/output devices for transfer of data or
results from storage.
It does not process or store data.
2) Arithmetic and Logical Unit:-
This unit consists of two subsections namely,
Arithmetic Section
Logic Section
15. Page 15 of 60
"Basic of computer science”
by Shubham Shewale
Arithmetic Section:-
Function of arithmetic section is to perform arithmetic operations like
addition, subtraction, multiplication, and division. All complex operations
are done by making repetitive use of the above operations.
Logic Section:-
Function of logic section is to perform logic operations such as
comparing, selecting, matching, and merging of data.
3) Memory Unit:-
Memory unit is the amount of data that can be stored in the
storage unit. This storage capacity is expressed in terms of Bytes.
This unit can store instructions, data, and intermediate results. This unit
supplies information to other units of the computer when needed. It is
also known as internal storage unit or the main memory or the primary
storage or Random Access Memory (RAM).
Its size affects speed, power, and capability. Primary memory and
secondary memory are two types of memories in the computer.
Functions of the memory unit are −
It stores all the data and the instructions required for processing.
It stores intermediate results of processing.
It stores the final results of processing before these results are
released to an output device.
All inputs and outputs are transmitted through the main memory.
16. Page 16 of 60
"Basic of computer science”
by Shubham Shewale
Storage‟s and Types:-
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
1) 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.
Advantages:-
The advantages of cache memory are as follows −
Cache memory is faster than main memory.
It consumes less access time as compared to main memory.
It stores the program that can be executed within a short period of
time.
It stores data for temporary use.
Disadvantages:-
The disadvantages of cache memory are as follows −
Cache memory has limited capacity.
It is very expensive.
17. Page 17 of 60
"Basic of computer science”
by Shubham Shewale
2) 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.
RAM:-
RAM (Random Access Memory) is the internal memory of the CPU
for storing data, program, and program result. It is a read/write
memory which stores data until the machine is working. As soon as
the machine is switched off, data is erased.
ROM:-
ROM stands for Read Only Memory. The memory from which we
can only read but cannot write on it. This type of memory is non-
volatile. The information is stored permanently in such memories
during manufacture. A ROM stores such instructions that are
required to start a computer. This operation is referred to
as bootstrap. ROM chips are not only used in the computer but
also in other electronic items like washing machine and microwave
oven.
3) 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.
18. Page 18 of 60
"Basic of computer science”
by Shubham Shewale
Compiler and Interpreter:-
Compiler:-
A compiler is a computer program that transforms code written in a high-
level programming language into the machine code. It is a program which
translates the human-readable code to a language a computer processor
understands. i.e. binary language 1’s and 0’s.
Interpreter:-
An interpreter is a computer program, which coverts each high-level
program statement into the machine code. This includes source code, pre-
compiled code, and scripts. Both compiler and interpreters do the same
job which is converting higher level programming language to machine
code. However, a compiler will convert the code into machine code (create
an exe) before program run. Interpreters convert code into machine code
when the program is run.
KEY DIFFERENCE
Compiler transforms code written in a high-level programming language
into the machine code, at once, before program runs, whereas Interpreter
coverts each high-level program statement, one by one, into the machine
code, during program runs.
Compiled code runs faster while interpreted code runs slower.
Compiler displays all errors after compilation; on the other hand, the
Interpreter displays errors of each line one by one.
Compiler is based on translation linking-loading model, whereas
Interpreter is based on Interpretation Method.
Compiler takes an entire program whereas the Interpreter takes a single
line of code.
19. Page 19 of 60
"Basic of computer science”
by Shubham Shewale
Bio-Mimicry:-
The word Bio- Mimicry defines itself – Bio means our background
that’s mean our nature and mimicry means copying, that’s mean
copying nature.
We can say,
It takes inspiration from natural selected solution
adopted by nature and translates the principles to human
engineering.
According to the Bio-mimicry Institute, bio-mimicry can be defined
as “an approach to innovation that seeks sustainable solutions to
human challenges by emulating nature’s time-tested patterns and
strategies. The goal is to create products, processes, and policies—
new ways of living—that are well-adapted to life on earth over the
long haul.”
The central idea is that nature has already fixed many problems
society is facing. Animals, plants, and microorganisms are
experienced engineers. They know what works, what’s appropriate,
and most importantly, what lasts on Earth. The main belief of the
bio-mimicry approach is that after 3, 8 billion years of research and
development, what did not work is now a fossil and what is around
us is the secret to survival.
Examples:
1. Gecko pads / Gloves or Climbing pads created by taking
inspiration from gecko (lizard) feet‟s.
2. Velcro straps (We can see this used in our sandals, gloves,
etc.) created by taking inspiration from Burr
3. Design of Jets created by taking inspiration from birds.
4. The first flying machine heavier than the air from the
Wright brothers, in 1903, was inspired by flying pigeons
5. The study of shark skin is at the origin of particularly
effective swimming suits, as well as a varnish for
plane‟s fuselage.
20. Page 20 of 60
"Basic of computer science”
by Shubham Shewale
Unplugged Activities:-
Unplugged activities consist of:
1) Decimal to Binary Conversation
2) Binary to Decimal Conversation
3) Text Conversation
4) Text Compression
5) Image Representation
6) Sound Representation
7) Minimal Spanning Tree
8) Searching Technique
9) Sorting Technique
Decimal to Binary Conversation:
COMPUTER only understands binary language i.e. 0’s and 1’s,
therefore if we want to give any input to the computer such as
decimal numbers then computer will convert our given input his
own language and then he will give us the Output.
This process is called as Decimal to Binary
Conversation.
For example: - Ramesh is from Telangana and he only
understands Telugu language, So if we want say something to
Ramesh then either we need to talk in Telugu or Ramesh should
have to convert our language to his own language, only after this
he will able to gave us any reply i.e. output.
Similarly, If we have entered 10 from keyboard
then Computer has to convert this Decimal number into his own
language i.e. Binary Language.
Now we will see how this process occurs in background:
Decimal Numbers: 0,1,2,3,4,5,6,7,8,9
Binary numbers: 0, 1
e.g. 1) Binary Conversation of Decimal Number 10
Solution:-
First of all we have to a draw table like this:
Note: power should be always written from left to right.
21. Page 21 of 60
"Basic of computer science”
by Shubham Shewale
Binary
Representat
ion
Binary
Chain
26
25
24
23
22
21
2
0
Solutions of
Binary
Chain
2x2x2x2x
2x2
=64
2x2x2x
2x2
=32
2x2x2
x2
=16
2x2
x2
=8
2x
2
=4
2x1
= 2
1
Now we have to Convert 10 to Binary, then find out addition of which
solutions is equals to 10, from below table and then just put 1’s over the
required solutions and 0’s to remaining all, are as follows:
Binary
Representat
ion
0 0 0 1 0 1 0
Binary
Chain
26
25
24
23
22
21
2
0
Solutions of
Binary
Chain
2x2x2x2x
2x2
=64
2x2x2x2
x2
=32
2x2x2
x2
=16
2x2x
2
=8
2x
2
=4
2x
1
=
2
1
Hence, Binary Representation of Decimal Number 10(8+2) will
be like: 0001010
We can also write this solution such as: 1010
e.g. 2) Binary Conversation of Decimal Number 25
Solution:
Now we have to Convert 25 to Binary, then find out addition
of which solutions is equals to 25, from below table and then
just put 1’s over the required solutions and 0’s to remaining
all, are as follows:
Binary
Representat
ion
0 0 1 1 0 0 1
Binary
Chain
26
25
24
23
22
21
2
0
Solutions of
Binary
Chain
2x2x2x2x
2x2
=64
2x2x2x2
x2
=32
2x2x2
x2
=16
2x2x
2
=8
2x
2
=4
2x
1
=
2
1
Hence, Binary Representation of Decimal Number
25(16+8+1) will be like: 0011001
We can also write this solution such as: 11001
22. Page 22 of 60
"Basic of computer science”
by Shubham Shewale
e.g. 3) Binary Conversation of Decimal Number 89
Solution:
Now we have to Convert 89 to Binary, then find out addition
of which solutions is equals to 89, from below table and then
just put 1’s over the required solutions and 0’s to remaining
all, are as follows:
Binary
Representat
ion
1 0 1 1 0 0 1
Binary
Chain
26
25
24
23
22
21
2
0
Solutions of
Binary
Chain
2x2x2x2x
2x2
=64
2x2x2x2
x2
=32
2x2x2
x2
=16
2x2x
2
=8
2x
2
=4
2x
1
=
2
1
Hence, Binary Representation of Decimal Number
89(64+16+8+1) will be like: 1011001
Binary to Decimal Conversation:
This is the reverse process of Binary to decimal conversation; if we
want convert any binary code to Decimal then we have to follow
this method:
e.g1) For Example, We have Binary Code 0000111 and we have to find
out decimal number of this code, then the solution will be like:
Draw our Conversation Table: Here we have put the given code from left
to right in our table over the Binary chain i.e. 20
, 21
…2n
Binary
Representat
ion
0 0 0 0 1 1 1
Binary
Chain
26
25
24
23
22
21
2
0
Solutions of
Binary
Chain
2x2x2x2x
2x2
=64
2x2x2x2
x2
=32
2x2x2
x2
=16
2x2
x2
=8
2x
2
=4
2x
1
= 2
1
Hence, Decimal Conversation of 0000111 = (4+2+1) = 7
23. Page 23 of 60
"Basic of computer science”
by Shubham Shewale
e.g. 2) For Example, We have Binary Code 01010 and we have to find
out decimal number of this code, then the solution will be like:
Draw our Conversation Table:
Here we have put the given code from left to right in our table over the
Binary chain i.e. 20
, 21
…2n
Binary
Representat
ion
0 1 0 1 0
Binary
Chain
26
25
24
23
22
21
2
0
Solutions of
Binary
Chain
2x2x2x2x
2x2
=64
2x2x2x2
x2
=32
2x2x2
x2
=16
2x2x
2
=8
2x
2
=4
2x
1
=
2
1
Hence, Decimal Conversation of 01010 = (8+2+1) = 11
e.g. 1) Find out decimal conversation of 1111111
Solution:
Binary
Representat
ion
1 1 1 1 1 1 1
Binary
Chain
26
25
24
23
22
21
2
0
Solutions of
Binary
Chain
2x2x2x2x
2x2
=64
2x2x2x2
x2
=32
2x2x2
x2
=16
2x2x
2
=8
2x
2
=4
2x
1
=
2
1
Hence, Decimal Conversation of 1111111 = (64+32+16+8+4+2+1) =
127
Text to Binary Conversation:
As we have seen that Computer doesn’t understand Decimal
numbers what we enter into it he convert it them into his own
language, similarly Computer also don’t understand the alphabets
that is any kind of text (a to z).
24. Page 24 of 60
"Basic of computer science”
by Shubham Shewale
**Text Conversation Method**
Here we have drawn a table such as: (A to Z characters Represents
1 to 26 decimal numbers):
1 2 3 4 5 6 7 8 9 10 11 12 13
A B C D E F G H I J K L M
Z Y X W V U T S R Q P O N
26 25 24 23 22 21 20 19 18 17 16 15 14
e.g.1) How to convert “S” in Binary Example: Suppose we
pressed ―S‖ from the keyboard then computer will convert this ―S‖
Character in binary code then he will able to respond to the user.
?
Solution:
We can see ―S‖ Character represents the Decimal number
―19‖, therefore we have to convert the decimal number 19 to
binary:
S = 19
Now we know the method how to convert decimal number into
binary,
Binary
Representat
ion
0 0 1 0 0 1 1
Binary
Chain
26
25
24
23
22
21
2
0
Solutions of
Binary
Chain
2x2x2x2x
2x2
=64
2x2x2x2
x2
=32
2x2x2
x2
=16
2x2x
2
=8
2x
2
=4
2x
1
=
2
1
From above table, binary of 19(16+2+1) = 0010011
We know that, we can also write this binary code such as: 10011
e.g. 2) How to Convert “Cap” into Binary?
Solution:
From above table:
―C‖ = 3, ―a‖ = 1, ―p‖ = 16
Now we know the method how to convert decimal number into
binary,
25. Page 25 of 60
"Basic of computer science”
by Shubham Shewale
Therefore,
Binary Conversation of
C = 3 = 11
a = 1 = 1
p = 16 = 10000
Therefore, Binary Conversation of ―Cap‖ = 11110000
e.g. 3) How to Convert “Mission Code” into Binary?
Solution:
From above table:
Mission:
M = 13, i = 9, s = 19, s = 19, i = 9, o = 15, n = 14
Code:
C= 3, o = 15, d = 4, e=5
Therefore,
M = 1101, i = 1001, s = 10011, s = 10011, i = 1001, o = 1111, n =
1110, C = 11, o = 1111, d = 100, e = 101
Therefore,
Binary conversation of ―Mission Code‖ = 1101 1001 10011 10011 1001
1111 1110 11 1111 100 101
Binary to Text Conversation:
1101 1001 10011 10011 1001 1111 1110
1101=13=M, 1001=9=I, 10011=19=S, 10011=19=S, 1001=9=I,
1111=15=0, 1110=14=N,
Therefore, 1101 1001 10011 10011 1001 1111 1110 = MISSION
26. Page 26 of 60
"Basic of computer science”
by Shubham Shewale
Text Compression:
With the help of Text compression algorithms or techniques we can
reduce memory storage while storing some repeated data.
Example:- Suppose, I have a bag and I have to put 8 dresses in that
bag, if I’ll put my clothes inappropriately then only 6 dresses can put into
that bag, But if I will do proper folding of my cloths then I can put all the
8 dresses into that bag.
Similarly, our computer’s memory storage is not infinite; we have to
do memory management of our data, thus if computer get some repeated
character’s from the user then he will occupy same memory for all
repeated data.
e.g. 1) compress this: JOHNY JOHNY YES PAPPA
Suppose, 1 character = 1 bit
Therefore, we have,
Characters Before
Compression
After
Compression
J 2 1
O 2 1
H 2 1
N 2 1
Y 3 1
E 1 1
S 1 1
P 3 1
A 2 1
Spaces 3 3
Total: 21 12
Here we can see, we have compressed 21 bits data into 12 bits.
We have saved 9 bits here.
(NOTE: Spaces will remain same after compression)
27. Page 27 of 60
"Basic of computer science”
by Shubham Shewale
e.g. 2) compress this: CHANDU KE CHACHA NE CHANDU KE
CHACHI KO CHANDI KE CHAMMACH SE CHATNI CHAKHAI
Suppose, 1 character = 1 bit
Therefore, we have,
Characters Before
Compression
After
Compression
C 11 1
H 12 1
A 11 1
N 5 1
D 3 1
U 2 1
K 5 1
E 5 1
I 4 1
O 1 1
M 2 1
S 1 1
T 1 1
Spaces 12 12
Total: 75 25
Here we can see, we have compressed 75 bits data into 25 bits.
We have saved 50 bits here.
28. Page 28 of 60
"Basic of computer science”
by Shubham Shewale
Image Representation:
As we know computer doesn’t understand numbers and alphabets,
similarly computer doesn’t understand images that’s mean he can’t
read the image directly, computer only understands 0’s and 1’s. So
image is made up of very small pixels, thus for computer the
shaded pixel is 0 and un-shaded pixel in 1.
Shaded pixel = 0
Un-shaded pixel = 1
e.g. 1) find out the binary representation of following image:
Solution:
Here, in above image
We have to write 0 for shaded pixel and 1 for un-shaded pixel.
Therefore,
Binary Representation of above image will be like:
100001
101111
100001
111101
100001
111111
i.e. 10001101111100001111101100001111111
We can also write this code like this:
(1, 0, 4, 1)
(1, 0, 1, 1, 1, 1, 1)
(1, 0, 4, 1)
(1, 1, 1, 1, 0, 1, 1)
(1, 0, 4, 1)
(1, 1, 1, 1, 1, 1)
29. Page 29 of 60
"Basic of computer science”
by Shubham Shewale
e.g. 2) draw the image from given code:
(1, 1, 0, 6, 1, 1)
(1, 0, 8, 1)
(0, 2, 1, 1, 0, 2, 1, 1, 0, 2)
(0, 2, 1, 1, 0, 2, 1, 1, 0, 2)
(0, 10)
(0, 10)
(0, 1, 1, 0, 6, 1, 0, 1)
(0, 2, 1, 0, 4, 1, 0, 2)
(1, 0, 2, 1, 1, 1, 1, 0, 2, 1)
(1, 1, 0, 2, 1, 1, 0, 2, 1, 1)
Solution:
0 = Shaded pixel
1 = un-shaded pixel
We will gate the image like this:
30. Page 30 of 60
"Basic of computer science”
by Shubham Shewale
Sound Representation:
As we know computer doesn’t understand numbers, text, images
similarly computer also don’t understand any kind of voice input. He
also converts that voice input in 0’s and 1’s.
Here in sound representation 1 stands for High pitch and 0
stands for low pitch,
For example: If computer hear the word ―CAT‖ then first of all we
have to find the decimal number of this alphabets, such as: C = 3,
A = 1, T = 20 then binary conversion of this decimal numbers
C = 3 = 11
A = 1 = 1
T = 20 = 10100
Sound Representation:
1 = High Pitch
1 1 1 1 1
0 0 0
0 = Low Pitch
31. Page 31 of 60
"Basic of computer science”
by Shubham Shewale
Minimal Spanning Tree:
Minimal spanning tree is a spanning tree that has minimum weight
than all other spanning trees of the same graph, in real world
situations this weight can be measured as distance, weight, or any
arbitrary value denoted to the edges.
For example:- Vinod is going to Mumbai tomorrow to attend
his entrance examination but the condition is that he has to
report at the exam center at Sharp 10:00 AM anyhow.
He has three options are as follows:
1) If he travel by bus, then he will reach his destination in
24 hours
2) If he travel by Train, then he will reach his destination
in 18 hours
3) If he travel by Plane, then he will reach his destination
in 8 hours
Therefore, to save the time and reach the destination in
time he preferred to travel by Plane.
e.g. 1)
8
5
9 6
10 9
Solution:
In above image A is the Initial Point and E is the Final Destination
Now we have to find out the minimum spanning tree for the above graph
Here, we have three possible spanning trees:
1) A+B+E = 5+8 = 13
2) A+C+E = 9+6 = 15
3) A+D+E = 10+9 = 19
Therefore the minimal spanning tree is: A+B+E = 5+8 =13
A
B
E
D
C
32. Page 32 of 60
"Basic of computer science”
by Shubham Shewale
Searching Technique:
Searching is an operation or a technique that helps to find the place
of a given element or value in the list. Any search is said to be
successful or unsuccessful depending upon whether the element
that is being searched is found or not.
Basically there is two types searching techniques are used are as
follows:
1. Linear Search
2. Binary Search
What is Linear Search?
This is the simplest method for searching. In this technique of searching,
the element to be found in searching the elements to be found is
searched sequentially in the list. This method can be performed on a
sorted or an unsorted list (usually arrays). In case of a sorted list
searching starts from 0th
element and continues until the element is found
from the list or the element whose value is greater than (assuming the
list is sorted in ascending order), the value being searched is reached.
As against this, searching in case of unsorted list also begins from the
0th
element and continues until the element or the end of the list is
reached.
Example: Suppose, There is 7 students in one exam hall there name is:
Shubham, Yogesh, Sampath, Afzal, Rajesh, Shrikanth, Rohit, and
there bench numbers are 1, 2, 3, 4, 5, 6, 7 respectively. He have some
message for Rohit but there exam is going on that’s why he can’t shout
loudly for asking who is Rohit here. So our linear search technique helped
that examiner to find out who is Rohit.
Let see how the examiner found Rohit from all of those students:
Students
Name
Shubham Yogesh Sampath Afzal Rajesh Shrikanth Rohit
Bench
Number
1 2 3 4 5 6 7
33. Page 33 of 60
"Basic of computer science”
by Shubham Shewale
Now, Examiner only knows that Bench number of Rohit is 7
Therefore he will check like this:
Step 1) He will check whether bench number 1=7?
No 1!=7
Step 2) He will check whether bench number 2=7?
No 2!=7
Step 3) He will check whether bench number 3=7?
No 3!=7
Step 4) He will check whether bench number 4=7?
No 4!=7
Step 5) He will check whether bench number 5=7?
No 5!=7
Step 6) He will check whether bench number 6=7?
No 6!=7
Step 7) He will check whether bench number 7=7?
Yes…! 7=7
Then, He will deliver the message to Rohit.
e.g. 1)
20 25 65 45 95 50 30
Find 45 in above array.
Solution:
Give index numbers to the given array:
A[0] A[1] A[2] A[3] A[4] A[5] A[6]
20 25 65 45 95 50 30
Step 1) search element [45] is compared with first element in the array
[20]
A[0] A[1] A[2] A[3] A[4] A[5] A[6]
20 25 65 45 95 50 30
Both are not matching, so move to the next element.
Step 2) search element [45] is compared with first element in the array
[25]
34. Page 34 of 60
"Basic of computer science”
by Shubham Shewale
A[0] A[1] A[2] A[3] A[4] A[5] A[6]
20 25 65 45 95 50 30
Both are not matching, so move to the next element.
Step 3) search element [45] is compared with first element in the array
[65]
A[0] A[1] A[2] A[3] A[4] A[5] A[6]
20 25 65 45 95 50 30
Both are not matching, so move to the next element.
Step 4) search element [45] is compared with first element in the array
[45]
A[0] A[1] A[2] A[3] A[4] A[5] A[6]
20 25 65 45 95 50 30
Both are matching, so we stop comparing and display element found at
index A[3]
What is Binary Search?
Binary search is a very fast and efficient searching technique. It requires
the list to be in sorted order. In this method, to search an element you
can compare it with the present element at the center of the list. If it
matches, then the search is successful otherwise the list is divided into
two halves: one from the 0th
element to the middle element which is the
center element (first half) another from the center element to the last
element (which is the 2nd
half) where all values are greater than the
center element.
The searching mechanism proceeds from either of the two halves
depending upon whether the target element is greater or smaller than the
central element. If the element is smaller than the central element, then
searching is done in the first half, otherwise searching is done in the
second half.
35. Page 35 of 60
"Basic of computer science”
by Shubham Shewale
e.g. 1):
10 12 20 25 30 45 62 70 91
Find the element 12 in above sorted array.
Solution:
Step 1) Search element 12 is compared with middle element 30
0 1 2 3 4 5 6 7 8
10 12 20 25 30 45 62 70 91
Both are not matching and 12 is smaller than 30, So we search only in
the left sublist [i. e. 10 12 20 25]
Step 2) Search element 12 is compared with middle element 12
0 1 2 3
10 12 20 25
Both are matching, So the result is: “Element 12 is found at index 1”
e.g. 2):
2 4 5 7 9 15 20 21 26 40
Find the element 40 in above sorted array.
Solution:
Step 1) Search element 40 is compared with middle element 9
0 1 2 3 4 5 6 7 8 9
2 4 5 7 9 15 20 21 26 40
Both are not matching and 40 is Greater than 9, So we search only in the
right sublist [i. e. 15 20 21 26 40]
Step 2) Search element 40 is compared with middle element 21
5 6 7 8 9
15 20 21 26 40
Both are not matching and 40 is Greater than 21, So we search only in
the right sublist [i. e. 26 40]
Step 2) Search element 40 is compared with middle element 26
Both are not matching, Therefore the remaining element must be our
search element 40.
Search element 40 found at index 9.
8 9
26 40
36. Page 36 of 60
"Basic of computer science”
by Shubham Shewale
Sorting Techniques:
Sorting is the operation performed to arrange the records of a table
or list in some order according to some specific ordering criteria.
Types of Sorting Techniques:
1. Bubble Sort
2. Selection Sort
3. Merge Sort
Bubble Sort:
Bubble Sort Algorithm is used to arrange N elements in ascending order,
and for that, you have to begin with 0th
element and compare it with the
first element. If the 0th
element is found greater than the 1st
element, then
the swapping operation will be performed, i.e., the two values will get
interchanged. In this way, all the elements of the array get compared.
Example: Suppose, in our school for National anthem and pray we
stand in a queue, so the criteria for making queue is; students should
stand in the ascending order by their heights, for this purpose we will
see how can we sort their height by using Bubble sort:
Student standing in unsorted order and their respective
heights in feet are as follows:
5.1 feet 4.2 feet 4.1 feet 6 feet 5.6
Solution: Suppose, Bubble denoted by green shaded box.
Pass1:
Initially our bubble will be on 0th
element
0 1 2 3 4
5.1 feet 4.2 feet 4.1 feet 6 feet 5.6
Here we check whether 5.1>4.2 if Yes then swap those elements, and
remaining element will remain as it is.
Now, our bubble will be on 1st
element
0 1 2 3 4
4.2 feet 5.1 feet 4.1 feet 6 feet 5.6
Here we check whether 5.1>4.1 if Yes then swap those elements, and
remaining element will remain as it is.
37. Page 37 of 60
"Basic of computer science”
by Shubham Shewale
Now, our bubble will be on 2nd
element
0 1 2 3 4
4.2 feet 4.1 feet 5.1 feet 6 feet 5.6
Here we check whether 5.1>6 if No then bubble will be shifted to the
next element and all the elements will remain same.
Now, our bubble will be on 3rd
element
0 1 2 3 4
4.2 feet 4.1 feet 5.1 feet 6 feet 5.6
Here we check whether 6>5.6 if Yes then swap those elements, and
remaining element will remain as it is.
0 1 2 3 4
4.2 feet 4.1 feet 5.1 feet 5.6 6 feet
At the end of Pass 1 we will gate the largest element will be
gone at last position
Pass 2:
Now again our bubble will be on 0th
element
0 1 2 3 4
4.2 feet 4.1 feet 5.1 feet 5.6 6 feet
Here we check whether 4.2>4.1 if yes then swap those elements, and
remaining element will remain as it is.
Here we got the sorted array:
0 1 2 3 4
4.1 feet 4.2 feet 5.1 feet 5.6 6 feet
Selection Sort:
The selection is a straightforward process of sorting values. In this
method, to sort the data in ascending order, the 0th
element is compared
with all other elements. If the 0th
element is found to be greater than the
compared element, the two values get interchanged. In this way after the
first iteration, the smallest element is placed at 0th
position. The technique
is repeated until the full array gets sorted.
38. Page 38 of 60
"Basic of computer science”
by Shubham Shewale
“In each Pass of the selection sort the smallest element is
selected from the unsorted sub-list and exchange with the
element at the beginning of the unsorted list.”
e.g.1) Sort the following list using Selection sort
7 2 3 8 1
Solution:
Pass 1: in first pass select the smallest element from the unsorted list
and exchange with the element at the beginning of the unsorted list.
1 2 3 8 7
Pass 2: Now, the smallest element 2 from the unsorted list is already at
the beginning of the unsorted list. So it will remain same in this pass.
1 2 3 8 7
Pass 3: Now, the smallest element 3 from the unsorted list is already at
the beginning of the unsorted list. So it will remain same in this pass.
1 2 3 8 7
Pass 4: Now select the smallest element from the unsorted list and
exchange with the element at the beginning of the unsorted list.
1 2 3 8 7
Hence our sorting has been done at Pass 4.
1 2 3 7 8
39. Page 39 of 60
"Basic of computer science”
by Shubham Shewale
Merge Sort:
This algorithm is based on splitting a list, into two comparable sized lists, i.e.,
left and right and then sorting each list and then merging the two sorted lists
back together as one.
e.g.1) Sort the following array using Merge Sort:
56 24 93 10 5 34 21
Solution: Here we have to divide the given array in 2 half‟s, do it
until we get the single-single element of the array and merge
them one by one by solving the problem that‟s mean just and
merge them together as one.
56 24 93 10 5 34 21
56 24 93 10 5 34 21
56 24 93 10 5 34 21
56 24 93 10 5 34 21
24 56 10 93 5 34 21
10 24 56 93 5 21 34
5 10 21 24 34 56 93
40. Page 40 of 60
"Basic of computer science”
by Shubham Shewale
Algorithem:
Algorithm can be defined as, ―A sequence of activities to be
processed for getting desired output from a given input.‖ A formula or set
of steps for solving a particular problem. To be an algorithm, a set of
rules must be unambiguous and have a clear stopping point‖. There may
be more than one way to solve a problem, so there may be more than
one algorithm for a problem. Now, if we take definition of algorithm as: ―A
sequence of activities to be processed for getting desired output from a
given input.‖
Then we can say that:
1. Getting specified output is essential after algorithm is executed.
2. One will get output only if algorithm stops after finite time.
3. Activities in an algorithm to be clearly defined in other words for
it to be unambiguous.
Before writing an algorithm for a problem, one should find out what
is/are the inputs to the algorithm and what is/are expected output after
running the algorithm. Now let us take some exercises to develop an
algorithm for some simple problems:
Example: Write algorithm to make a Tea
Step 1: Start the gas
Step 2: Take a pot and some milk into it
Step 3: add some sugar and Tea powder as per need
Step 4: Boil it until the tea get prepared perfectly.
Step 5: stop.
41. Page 41 of 60
"Basic of computer science”
by Shubham Shewale
e.g. 1): write algorithm to find the greater number between two
numbers
Step1: Start
Step2: Read/input A and B
Step3: If A greater than B then C=A
Step4: if B greater than A then C=B
Step5: Print C
Step6: End
e.g. 2): Write an algorithm to read two numbers and find their
sum.
Step1: Start
Step2: Readinput the first num1.
Step3: Readinput the second num2.
Step4: Sum num1+num2 // calculation of sum
Step5: Print Sum
Step6: End
42. Page 42 of 60
"Basic of computer science”
by Shubham Shewale
Flowchart:
The flowchart is a diagram which visually presents the
flow of data through processing systems. This means by seeing a
flow chart one can know the operations performed and the
sequence of these operations in a system.
Algorithms are nothing but sequence of steps for solving
problems. So a flow chart can be used for representing an
algorithm. A flowchart, will describe the operations (and in what
sequence) are required to solve a given problem. You can see a flow
chart as a blueprint of a design you have made for solving a
problem.
What is the need of Flowchart???
1. It is usually much easier to draw a flowchart of a
problem and then to write a program directly.
2. Flowchart is an important aid in the development of the
algorithm itself.
3. Easier to understand than a program itself.
4. Independent of any particular programming languages.
5. It saves time while writing the program.
For example: suppose you are going for a picnic with your friends
then you plan for the activities you will do there. If you have a plan
of activities then you know clearly when you will do what activity.
Similarly when you have a problem to solve using computer or in
other word you need to write a computer program for a problem
then it will be good to draw a flowchart prior to writing a computer
program.
Flowchart is drawn according to defined rules are as follows:
Flowchart Symbols:
There are 6 basic symbols commonly used in flowcharting of
assembly language Programs: Terminal, Process, input/output,
Decision, Connector and Predefined Process. This is not a complete
list of all the possible flowcharting symbols; it is the ones used most
often in the structure of Assembly language programming.
General Rules for flowcharting:
1. All boxes of the flowchart are connected with Arrows.
43. Page 43 of 60
"Basic of computer science”
by Shubham Shewale
2. Flowchart symbols have an entry point on the top of the symbol
with no other entry points. The exit point for all flowchart symbols is
on the bottom except for the Decision symbol.
3. The Decision symbol has two exit points; these can be on the
sides or the bottom and one side.
4. Generally a flowchart will flow from top to bottom. However, an
upward flow can be shown as long as it does not exceed 3 symbols.
5. Connectors are used to connect breaks in the flowchart.
Examples are:
From one page to another page.
From the bottom of the page to the top of the same page.
An upward flow of more than 3 symbols
6. Subroutines and Interrupt programs have their own and
independent flowcharts.
7. All flow charts start with a Terminal or Predefined Process (for
interrupt programs or subroutines) symbol.
8. All flowcharts end with a terminal or a contentious loop.
Flowcharting uses symbols that have been in use for a
number of years to represent the type of operations and/or
processes being performed. The standardised format provides a
common method for people to visualise problems together in the
same manner. The use of standardised symbols makes the flow
charts easier to interpret; however, standardizing symbols is not as
important as the sequence of activities that make up the process.
44. Page 44 of 60
"Basic of computer science”
by Shubham Shewale
Creating a flowchart:
1. START (Terminal Box)
2. INPUT two numbers (Input / Output Box)
3. Add the numbers (Process Box)
4. Print Result (Input / Output Box)
5. STOP (Terminal Box)
Let‟s do it…!
START
Input A, B
Sum = A+B
Print Sum
STOP
45. Page 45 of 60
"Basic of computer science”
by Shubham Shewale
e.g.1: Draw a flowchart for to send a letter by post to your
friend.
Solution:
YES NO
START
Take a blank paper and a
pen
Write a letter
Put it inside an envelope and close it
Write the address of your friend on the
envelope
Do youhave
Stamps?
Buy Stamps
Stick the stamps on the envelope
Drop the letter into the letter Box
STOP
46. Page 46 of 60
"Basic of computer science”
by Shubham Shewale
Programming:-
Programming is the process of creating a set of instructions that
tell a computer how to perform a task.
Programming Language: A programming language is
a computer language that is used by programmers (developers)
to communicate with computers. It is a set of instructions written in
any specific language to perform a specific task
Top 10 Programming Languages:
1. Python
2. JavaScript
3. JAVA
4. C#
5. C
6. C++
7. GO
8. R
9. PHP
Introduction to Python:-
Python is a widely used general-purpose, high level programming
language. It was created by Guido van Rossum in 1991 and
further developed by the Python Software Foundation. It was
designed with an emphasis on code readability, and its syntax
allows programmers to express their concepts in fewer lines of
code.
What Makes Python Special?
1. Python has very simple and less syntax.
2. Easy to understand.
3. Python is the kind of programming language, If someone is not
having knowledge of programming then he can also learn
python.
4. High- level i.e. human understandable language.
47. Page 47 of 60
"Basic of computer science”
by Shubham Shewale
Variables:-
In simple language, variables can be anything that stores data that
user want to store and use it whenever he wants.
A variable is a quantity that may change within the context of a
mathematical problem or experiment. Typically, we use a single
letter or any combinations of the letters to represent a variable.
e.g:- a, b, c or Age, Math, etc.
for example:- if I want to store a number 10, then I will create a
variable to store that number 10. Such as, num= 10, here we can
see num is the variables where we stored a value 10.
Data types:-
A data type, in programming, is a classification that
specifies which type of value a variable has and what type of
mathematical, relational or logical operations can be applied to it
without causing an error. A string, for example, is a data type that
is used to classify text and an integer is a data type used to
classify whole numbers.
Data type Used for Examples
String (str) Alphanumeric
characters
Hello world, Pin is
431721
Integer (int) Whole numbers 1, 25, 8965
Float (float) Number with decimal
point
0.3, 8.9, 85.96
For example:- if I want to store heights of students, then as we
know height is measured in decimal numbers such as: 5.6 i.e. 5
feet 6 inches , therefore I will take variables of data type float.
48. Page 48 of 60
"Basic of computer science”
by Shubham Shewale
Print statement:- print()
The print function is used to print the output desired by the user.
For example:- If I want to print my name, then first I will create a
variable to store my name and then I will print that variable.
Such as:
a=shubham
Print(a)
Operators:-
Arithmetic operators are used with numeric values to perform
common mathematical operations i.e. addition, subtraction,
multiplication and division. Also logical operators such as: and, or,
not
Operators Use Examples
+ Addition a+b
- Subtraction a-b
* Multiplication A*b
/ Division a/b
and/or Merging two conditions a>b and a>c
Examples using operators:
addition of two numbers given by the user.
a=int(input(―Enter first number:‖))
b=int(input(―Enter second number‖))
addition=a+b
print(―Addition of two numbers is:‖,addition)
49. Page 49 of 60
"Basic of computer science”
by Shubham Shewale
Conditional Statements:
There is three types of conditional statements, are as follows:
1. if
2. if….else
3. if….elif….else
1) if condition: An "if statement" is written by using the if keyword.
if condition is used when we have only one condition.
For example:- I want to boil water, then my condition will be, until
the water will not get boiled I will not turn off the stove.
The above example is represented using flowchart to display how
the “if condition” works.
No Yes
Start
Pot, Water, Stove
Turn on the stove
If
the
wate
Continue the
process
Turn off the
stove
Stop
50. Page 50 of 60
"Basic of computer science”
by Shubham Shewale
Examples using if condition:-
1. Write a program to find the greatest number among two given
values.
Code:-
a=10
b=5
if a>b:
print(a,―is a greater number!‖)
2. Write a program to check whether the number is positive or
not.
Code:-
a=int(input(―Enter any number‖))
if a>=0
print(―The number is positive‖)
2) if….else condition:
An "if…else statement" is written by using if and else keyword.
If…else condition is used when we have two conditions.
For example:- I want to know whether the candidate is eligible for
vote or not
The above example is represented using flowchart to display how
the “if…else condition” works.
Start
Age
51. Page 51 of 60
"Basic of computer science”
by Shubham Shewale
No Yes
Examples using if…else condition:-
1. Write a program to find the whether the candidate is eligible for
vote or not
Age=int(input(―Enter your age:‖))
if Age>=18:
print(―Eligible for vote!‖)
else:
print(―Not Eligible for vote!‖)
2. Write a program to check whether the number even or odd.
a=int(input(―Enter any number:‖))
if a%2==0:
print(―The number is even‖)
else:
print(―The number is odd‖)
3) if…elif…else Condition:-
Age>=1
Stop
Not Eligible
for vote
Eligible for
vote
52. Page 52 of 60
"Basic of computer science”
by Shubham Shewale
An "if…elif…else statement" is written by using if, elif and
else keyword.
If…elif…else condition is used when we have more than two
conditions.
For example:- If I want to know greatest number among three
numbers
The above example is represented using flowchart to display how the
“if…elif…else condition” works.
Start
Num1, num2, num3
Stop
If
Num1>Num
2 and
Num1>Num
33
Elif
Num2>Num
1 and
Num2>Num
3
Else
Num1 is
Greater
Num2 is
Greater
Num3 is
Greater
53. Page 53 of 60
"Basic of computer science”
by Shubham Shewale
Examples using if…elif…else condition:-
1. Find greatest number among three numbers
num1=int(input(―enter first number:‖))
num2=int(input(―enter second number:‖))
num3=int(input(―enter third number:‖))
if num1>num2 and num1>num3:
print(―num1 is greater‖)
elif num2>num1 and num2>num3:
print(―num2 is greater‖)
else:
print(―num3 is greater‖)
2. write a program to print status of their age(like
child/teenage/adult/old age)
age=int(input(―enter your age:‖))
if age>=1 and age<=12:
print(―Child‖)
elif age>12 and age<18:
print(―Teenage‖)
elif age>18 and age<60:
print(―Adult‖)
else:
print(―Old age‖)
54. Page 54 of 60
"Basic of computer science”
by Shubham Shewale
Looping Statements:-
Looping Statements in python execute the sequence of statements many
times until the stated condition becomes false.
There are two types of looping statements available in python, are as
follows:
1. While Loop (while)
2. For Loop (for)
1. While Loop (while):-
A while loop is a control flow statement that allows code to be executed repeatedly
based on a given Boolean condition.
Examples using while loop:-
1. Write a program to print number 1 to 10 using while loop.
a=0
while(a<10):
a=a+1
print(a)
2. Write a program to print number 5 to 10 using while loop.
a=5
while(a<10):
a=a+1
print(a)
3. Write a program to print number 10 to 1 using while loop.
a=10
while(a>0):
a=a-1
print(a)
1. For Loop (for):-
55. Page 55 of 60
"Basic of computer science”
by Shubham Shewale
A for loop is a repetition control structure that allows you to efficiently
write a loop that needs to execute a specific number of times.
Examples using while loop:-
1. Write a program to print number 1 to 10 using for loop.
a=10
for i in range(0,a):
print(i)
2. Write a program to print number 5 to 10 using for loop.
a=10
for i in range(5,a):
print(i)
56. Page 56 of 60
"Basic of computer science”
by Shubham Shewale
Problem Solving Techniques:-
Problem solving technique is the technical process to find an optimal
solution of any kind of problem we face in our day-to-day life.
6 steps of problem solving techniques:-
1) Define
2) Ideate
3) Plan
4) Build
5) Test
6) Implement
For Example:- I have a big problem of garbage in my area, I will solve
this problem using Problem Solving technique as below:
1) Define :- Define any problem means, understood the actual reason or
the source of problem so we will know what is the actual problem is.
2) Ideate :- for above example, I will have to think about the problem
and create some ideas to solve the problem.
3) Plan :- for that idea I have to create a plan, So that’s mean I will gate
an pre-Implementation concept of my plan
4) Build :- for that plan, I have to build a structure of my solutions so I
can understand how my plan will work.
5) Test :- Then I have to test that plan so in case the plan not works
properly I can change it before implementation.
6) Implement :- Once the whole plan worked properly, I can implement
the plan to solve my problem.
Define
Build Test Imple
m-ent
Plan
Ideate
57. Page 57 of 60
"Basic of computer science”
by Shubham Shewale
Technology:-
―Technology is the sum of techniques, skills, methods, and
processes used in the production of goods or services or in the
accomplishment of objectives, such as scientific investigation.‖
How DISCOVERY differs from INNOVATION?
A discovery is recognizing something that already exists for the
first time that nobody has found before, e.g. how Christopher
Columbus discovered the Americas.
An innovation is creating something totally new with one's own
ideas and development. ... e.g. how Thomas Edison invented
the light bulb.
Is technology development harm in real life???
Technology may harm in some way such overuse of devices may
harm our eyes, etc. but technology development never had any
intentions to harm human beings. „That‟s why technology
development doesn‟t harm in real life!‟, because we have
seen that all the inventions invented by taking inspiration from
natural selected solution that is nothing but Bio-Mimicry.
Advantages:
Increased Production. Technology has considerably increased
effectiveness and helped businesses across many industries. ...
Easily Accessible. Technology has made our life very easy. ...
Increased Job Opportunities. ...
Better Communication. ...
Different Learning Methods.
Real time examples of technology development in current
scenario:
1) Metro train - for fastest transportation.
2) Android – lots of application can run in android
and we can use it from any corner of the world it
58. Page 58 of 60
"Basic of computer science”
by Shubham Shewale
is actually a pocket size dynamo…world become
easier and faster!
3) Washing Machine – now we can wash our cloths
using technology it takes very less efforts.
4) Refrigerators – now we can cool water and cold
drinks at our home and can use vegetables and
fruits for longer than usual time.
5) Robots - We can do our work using robot it is the
best invention till now.
6) Camera – we can take pictures to save our
memories.
7) Interactive Whiteboards – We can see this in
our classrooms, how helpful this boards for
teaching as well as learning purpose.
Sensors –
A sensor is a device, module, machine, or subsystem
whose purpose is to detect events or changes in its environment and send
the information to other electronics, frequently a computer processor. A
sensor is always used with other electronics.
Uses of sensors:-
It can be used for our real life problem solving. It is
use to detect events or changes in its environment and send the
information to other electronics, frequently a computer processor.
Examples:-
1) Speed Sensor – we can see, it is used in our vehicles to detect the
speed, also in the cricket match to detect the speed of the ball.
2) Temperature Sensor – In now days can we can see there is a
gadget available in the market to detect the temperature of body.
A device which gives temperature
measurement as an electrical signal is called as Temperature
sensor. This electrical signal will be in the form of electrical voltage
and is proportional to the temperature measurement.
3) Ultrasonic Sensor - To measure the distance.. it is used in
vehicles.
4) PIR Sensor – it can be used for automatic door closing and
opening
59. Page 59 of 60
"Basic of computer science”
by Shubham Shewale
Every object that has a temperature above
absolute zero emit heat energy in the form of radiation radiating at
infrared wavelengths which is invisible to the human eye, but can
be detected by special purpose electronic devices such as PIR
motion detectors.
IoT : Internet of things
The Internet of things describes the network of physical objects—
―things‖ or objects—that are embedded with sensors, software, and
other technologies for the purpose of connecting and exchanging
data with other devices and systems over the Internet.
It is a system of interrelated,
internet-connected objects that are able to collect and transfer data
over a wireless network without human intervention. The personal
or business possibilities are endless.
The Internet of Things, or IoT, refers to the billions of
physical devices around the world that are now connected to the
internet, all collecting and sharing data. Thanks to the arrival of
super-cheap computer chips and the ubiquity of wireless networks,
it's possible to turn anything, from something as small as a pill to
something as big as an aeroplane, into a part of the IoT. Connecting
up all these different objects and adding sensors to them adds a
level of digital intelligence to devices that would be otherwise dumb,
enabling them to communicate real-time data without involving a
human being. The Internet of Things is making the fabric of the
world around us more smarter and more responsive, merging the
digital and physical universes.
Development boards:
Microprocessor board: which does multiple task at a single
time…multitasking
Microcontroller board: where we can do the single task
multiple times
60. Page 60 of 60
"Basic of computer science”
by Shubham Shewale
LED Blinking project:
Here, we are doing a small project of LED blinking which can be
utilized for Traffic light signal purpose.
For this, we need 1 Arduino Uno board, 3 LED lights and wires
which are all physical components, let see what is the logic hidden
behind this:
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(7, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(10000); // Wait for 10 seconds
digitalWrite(13, LOW);
delay(10000);
digitalWrite(12, HIGH);
delay(10000);
digitalWrite(12, LOW);
delay(10000);
digitalWrite(7, HIGH);
delay(10000);
digitalWrite(7, LOW);
delay(10000);
}
In above program, we used 3 pinMode (i.e. Green signal, Yellow
signal and Red signal) for 3 LED’s then we used all pinMode’s one
by one where we gave them a command to get blinked (HIGH) for
10 seconds and then off(LOW) for 10 seconds.
.