Computer Science: Python
Computer Science: Python
OF
COMPUTER SCIENCE
WITH
PYTHON
CLASS XI INCLUDES
FR
EE
PRACTICAL
WORKBOOK
HARSH BHASIN
TEXTBOOK
OF
COMPUTER SCIENCE
WITH
PYTHON
CLASS XI
SECOND
EDITION
BRANCHES
• Bangalore 37/10, 8th Cross (Near Hanuman Temple), Azad Nagar, Chamarajpet, Bangalore- 560 018
Tel.: (080) 26756823, Mob.: 9315905288, E-mail: [email protected]
• Chennai 26, Damodaran Street, T. Nagar, Chennai-600 017, Tel.: (044) 24353401, Mob.: 9315905309
E-mail: [email protected]
• Guwahati Hemsen Complex, Mohd. Shah Road, Paltan Bazar, Near Starline Hotel
Guwahati-781 008, Tel.: (0361) 2513881, Mob.: 9315905296, E-mail: [email protected]
• Hyderabad 105, 1st Floor, Madhiray Kaveri Tower, 3-2-19, Azam Jahi Road, Near Kumar Theater
Nimboliadda Kachiguda, Hyderabad-500 027, Tel.: (040) 24652456, Mob.: 9315905326
E-mail: [email protected]
• Kolkata RDB Chambers (Formerly Lotus Cinema) 106A, 1st Floor, S N Banerjee Road
Kolkata-700 014, Tel.: (033) 22273773, Mob.: 9315905319, E-mail: [email protected]
• Mumbai 142C, Victor House, Ground Floor, N.M. Joshi Marg, Lower Parel, Mumbai-400 013
Tel.: (022) 24927869, 24915415, Mob.: 9315905282, E-mail: [email protected]
• New Delhi 22, Golden House, Daryaganj, New Delhi-110 002, Tel.: (011) 23262368, 23262370
Mob.: 9315905300, E-mail: [email protected]
(v)
Contents
Preface (v)
Acknowledgements (vi)
Syllabus (vii)
UNIT–I: COMPUTER SYSTEM AND ORGANIZATION
1. Basic Computer Organization 3
1.1 Introduction to Computer System 3
1.2 Fundamentals 4
1.3 Hardware 5
1.3.1 Input Devices 5
1.3.2 Output Devices 6
1.4 Software 7
1.4.1 Data 8
1.4.2 Booting 8
1.4.3 Language Translators 8
1.4.4 Compiler and Interpreter 9
1.4.5 Assembler 10
1.4.6 Linker and Loader 10
1.4.7 System Software and System Utilities 11
1.4.8 Device Drivers 13
1.4.9 Operating Systems 14
1.5 Computer System Architecture 14
1.5.1 Bus 15
1.5.2 Central Processing Unit (CPU) 15
1.5.3 Arithmetic Logic Unit (ALU) 16
1.5.4 Control Unit 17
1.6 Memory 17
1.6.1 Various Types of ROM 18
1.6.2 Various Types of RAM 18
1.6.3 Primary Memory and Secondary Memory 18
1.6.4 Cache Memory 19
1.6.5 Hard Disk Drive 19
1.7 Stored Program Concept 20
1.8 Programming Tools 20
1.9 Conclusion 20
Points to Remember 21
Exercises 22
2. Number Systems 26
2.1 Introduction 26
2.2 Decimal Number System 27
2.3 Binary Numbers 27
2.3.1 Decimal to Binary 27
2.3.2 Binary to Decimal 28
2.4 Octal Numbers 29
2.4.1 Decimal to Octal 30
2.4.2 Octal to Decimal 30
(xi)
2.5 Hexadecimal Number System 31
2.5.1 Decimal to Hexadecimal 32
2.5.2 Hexadecimal to Decimal 32
2.6 Octal and Hexadecimal to Binary and Vice-versa 33
2.6.1 Octal to Binary and Vice-versa 33
2.6.2 Hexadecimal to Binary and Vice-versa 34
2.7 Conclusion 35
Points to Remember 35
Exercises 35
3. Boolean Algebra and Logic Gates 43
3.1 Introduction 43
3.2 Boolean Variable 43
3.3 Boolean Operators 44
3.4 Truth Table 45
3.5 Logic Gates 45
3.5.1 The AND Gate 46
3.5.2 The OR Gate 46
3.5.3 The NOT Gate 47
3.5.4 The NAND Gate 48
3.5.5 The NOR Gate 49
3.5.6 The XOR Gate 49
3.5.7 The XNOR Gate 50
3.6 Basic Logic Gates from Universal Gates 50
3.6.1 Basic Gates from NAND Gate 50
3.6.2 Basic Gates from NOR Gate 51
3.7 Properties of Boolean Algebra 53
3.7.1 ORing and ANDing with 0 and 1 53
3.7.2 Properties Related to Complement 54
3.7.3 Commutative and Associative Properties 54
3.7.4 Distributive Properties and Absorption Law 55
3.7.5 Dual 55
3.8 De-Morgan’s Laws 56
3.9 Conclusion 57
Points to Remember 57
Exercises 58
4. Codes 75
4.1 Introduction 75
4.2 ASCII Code 75
4.3 ISCII Code 78
4.4 Unicode 79
4.5 Conclusion 80
Points to Remember 80
Exercises 80
UNIT–II: COMPUTATIONAL THINKING AND PROGRAMMING - 1
5. Introduction to Problem Solving 85
5.1 Introduction 85
5.2 Steps for Problem Solving 85
5.3 Problem Solving Using Decomposition 86
(xii)
5.4 Algorithm 87
5.5 Algorithms: Definition and Characteristics 88
5.6 Pseudo Code and Flow Chart 88
5.7 Conclusion 91
Points to Remember 92
Exercises 92
6. Familiarization with the Basics of Python Programming 94
6.1 Introduction to Python 94
6.2 Features of Python 95
6.2.1 Easy 95
6.2.2 Type and Run 95
6.2.3 Syntax 95
6.2.4 Mixing 95
6.2.5 Dynamic Typing 96
6.2.6 Built-in Object Types 96
6.2.7 Numerous Libraries and Tools 96
6.2.8 Portable 96
6.2.9 Free 96
6.3 The Paradigms 96
6.3.1 Procedural 96
6.3.2 Object-Oriented 96
6.3.3 Functional 96
6.4 Chronology 97
6.4.1 Uses 98
6.5 Installation of Anaconda 98
6.6 Conclusion 103
Points to Remember 104
Exercises 104
7. Fundamentals of Python 108
7.1 Introduction 108
7.2 Basic Input Output 110
7.2.1 Hello World Program 110
7.2.2 Input 110
7.3 Program Execution 111
7.3.1 Interactive Mode : Using the Command Prompt 111
7.3.2 Script Mode : Executing Programs Written in .py Files 112
7.3.3 Using Anaconda Navigator 113
7.4 The Jupyter Notebook 114
7.5 Value Type and Reference Type 116
7.6 Python Character Set : Tokens, Keywords, Identifiers, Literals and Punctuators 117
7.6.1 Python Keywords 117
7.6.2 Python Identifiers 118
7.6.3 Python Escape Sequence 118
7.6.4 Punctuators 118
7.6.5 Literals 118
7.7 Statements 120
7.7.1 Expression Statement 120
7.7.2 Assignment Statements 121
7.7.3 The assert Statements 121
(xiii)
7.7.4 The Pass Statements 121
7.7.5 The Control Statements 121
7.8 Comments 121
7.9 Operators 122
7.10 Types and Examples of Operators 123
7.10.1 Arithmetic Operators 123
7.10.2 String Operators 124
7.10.3 Relational Operators 125
7.10.4 Assignment Operators 125
7.10.5 Logical Operators 126
7.10.6 Priority of Operators 127
7.11 Basic Data Types 128
7.11.1 Integer 128
7.11.2 Float 129
7.11.3 String 129
7.11.4 Complex 130
7.11.5 Boolean 130
7.11.6 None 130
7.11.7 Mutable and Immutable Types 131
7.12 Errors 131
7.12.1 Syntax Errors 131
7.12.2 Runtime Errors 132
7.12.3 Logical Errors 132
7.12.4 L-value and R-value 132
7.13 Flow of Control 133
7.14 Conclusion 134
Points to Remember 135
Exercises 136
8. Lists 140
8.1 Introduction 140
8.2 Lists 141
8.3 Eval() Function 141
8.4 Accessing Elements: Indexing and Slicing 142
8.4.1 Indexing 143
8.4.2 Slicing 143
8.5 Mutability 145
8.6 List Operations 145
8.7 Traversing List Using Loops 146
8.8 Making a True Copy of a List 147
8.9 Functions 147
8.10 Illustrations 151
8.11 Conclusion 157
Points to Remember 157
Exercises 157
9. Tuples 162
9.1 Introduction 162
9.2 Tuple 162
9.3 Indexing and Slicing 163
9.4 Non-Mutability 165
(xiv)
9.5 Tuple Operations 165
9.6 Traversal 166
9.7 Functions 167
9.8 Conclusion 170
Points to Remember 170
Exercises 170
10. Dictionary 174
10.1 Introduction 174
10.2 Associative Arrays and Dictionaries 175
10.3 Displaying Elements of a Dictionary 177
10.3.1 Items 177
10.3.2 Built-in Functions 177
10.3.3 Keys 178
10.3.4 Values 178
10.4 Important Points Regarding Dictionary 178
10.5 Some Important Built-in Functions of Dictionaries 179
10.5.1 Len 179
10.5.2 Max 179
10.5.3 Min 180
10.5.4 Sorted 180
10.5.5 Pop 180
10.6 Input from the User 181
10.7 Making a Shallow Copy of a Dictionary 181
10.8 Illustrations 182
10.9 Conclusion 184
Points to Remember 184
Exercises 185
11. Strings 188
11.1 Introduction 188
11.2 Traversing String Using Loops 188
11.3 String Operations 191
11.3.1 The Concatenation Operator (+) 191
11.3.2 The Replication Operator (*) 191
11.3.3 The Membership Operator 192
11.3.4 Slicing 192
11.4 In-built Functions 193
11.4.1 len() 193
11.4.2 capitalize() 193
11.4.3 find() 194
11.4.4 count() 194
11.4.5 endswith() 194
11.4.6 strip() 195
11.4.7 title() 195
11.4.8 split() 195
11.4.9 partition() 196
11.4.10 Miscellaneous Functions 196
11.5 Illustrations 199
11.6 Conclusion 203
Points to Remember 203
Exercises 203
(xv)
12. Conditional Statements 207
12.1 Introduction 207
12.2 ‘if’, if-else and if-elif-else Constructs 208
12.3 The if-elif-else Ladder 213
12.4 Logical Operators 213
12.5 The Ternary Operator 214
12.6 The Get Construct 215
12.7 Examples 216
12.8 Conclusion 220
Points to Remember 221
Exercises 221
13. Looping 225
13.1 Introduction 225
13.2 Looping Constructs 226
13.2.1 While Loop 227
13.2.2 For Loop 227
13.3 Range, Break and Continue 228
13.4 Illustrations 229
13.5 while-else 236
13.6 Nested Loops 236
13.7 Generating Patterns 237
13.8 Conclusion 241
Points to Remember 242
Exercises 242
14. Sorting Techniques (Not in Syllabus)245
14.1 Introduction 245
14.2 Selection Sort 246
14.2.1 Complexity 248
14.2.2 Algorithm 249
14.2.3 Program 249
14.3 Bubble Sort 250
14.3.1 Complexity 253
14.3.2 Algorithm 254
14.3.3 Program 254
14.4 Insertion Sort 255
14.4.1 Algorithm 256
14.4.2 Complexity 257
14.5 Conclusion 257
Points to Remember 258
Exercises 258
15. Introduction to Python Modules 261
15.1 Introduction 261
15.2 Creating Modules and Packages in Python 263
15.3 Accessing Objects of a Module 265
15.3.1 Importing an Object from Module 266
15.3.2 Importing Many Objects from Module 266
15.3.3 Importing the Whole Module 266
15.4 Math, Random and Statistics Modules 269
(xvi)
15.4.1 Math Module 269
15.4.2 Random Module 270
15.4.3 Statistics Module 270
15.5 NumPy 271
15.5.1 Functions for Generating Sequences 273
15.5.2 Aggregate Functions 274
15.6 Conclusion 276
Points to Remember 276
Exercises 277
UNIT–III: SOCIETY, LAW AND ETHICS
16. Society, Law and Ethics–I283
16.1 Introduction 283
16.2 Malware 284
16.3 Virus 284
16.3.1 How does it Work? 284
16.3.2 Phases of Computer Virus 285
16.4 Worms 285
16.5 Trojans 285
16.6 Spyware 286
16.6.1 Problems 287
16.7 Adware 287
16.8 Cookies 288
16.9 Digital Footprints 288
16.10 Cyber Crime 289
16.11 Cyber Bullying 289
16.11.1 Types of Cyber Bullying 290
16.11.2 Implications 290
16.11.3 Prevention 291
16.12 Identity Thefts 291
16.12.1 Types of Identity Theft 292
16.12.2 Recovery 292
16.12.3 Precautions 292
16.13 Phishing 293
16.13.1 Phishing Techniques 293
16.13.2 How to Prevent Phishing 293
16.14 Pharming 293
16.15 PC Intrusion 293
16.16 Eavesdropping 293
16.17 Trolling 294
16.18 Spamming 294
16.19 Spreading Rumours 294
16.20 Credit Card Frauds 295
16.21 Cyber Stalking 295
16.22 Illegal Downloading and Digital Piracy 295
16.23 Child Pornography 296
16.24 How to Prevent Computer Viruses 296
16.25 How to Prevent Phishing 296
16.26 How to Prevent Pharming 296
(xvii)
16.27 How to Prevent Eavesdropping 297
16.28 How to Prevent Spamming 297
16.29 Firewall 297
16.30 Authentication 297
16.31 Social Media: Common Networking Sites and Appropriate usage 298
16.31.1 What must you Remember while Creating an Account on Facebook 299
16.32 Social Media Etiquettes 300
16.33 Safely Browsing the Internet 300
16.33.1 Identity Thefts and Identity Protection 300
16.33.2 Creating a Strong Password 300
16.33.3 Don’t Copy Anyone’s Work 300
16.34 Information Technology Act 2000 301
16.34.1 Features 301
16.34.2 Non-Applicability 301
16.34.3 Amendment 2008 302
16.35 Conclusion 303
Points to Remember 303
Exercises 304
17. Society, Law and Ethics–II 311
17.1 Introduction 311
17.2 Plagiarism 311
17.3 Intellectual Property 312
17.3.1 Copyright 312
17.3.2 Trademarks 312
17.3.3 Patents 312
17.4 Copyright Infringement 313
17.5 Trademark Infringement 313
17.6 Licensing 313
17.6.1 FOSS 313
17.6.2 Academic Free License 314
17.6.3 Apache License 314
17.6.4 BSD 314
17.6.5 Creative Common Zero 314
17.6.6 GNU General Public License 314
17.7 Open Movement: Open Data and Open Source 315
17.7.1 Open Data 315
17.7.2 Open Source 315
17.8 Technology and Society 316
17.9 Education for All 317
17.9.1 Gender Issues 317
17.9.2 Disability Issues 317
17.10 Electronic Waste Management 318
17.11 Conclusion 319
Points to Remember 319
Exercises 320
(xviii)
Basic Computer
1 Organization
3
• Speed: Imagine you have to sort a list of a million numbers manually. How long will you take?
The computers will accomplish the same task in a few seconds. Likewise, there are many
computational tasks, which can be done by a computer in a fraction of a second.
• Reliance: You can rely on the computer, for your data, the results it produces, the organization
of information, and for the efficient retrieval of information.
• Accurate: Provided your algorithm is correct, the computers produce accurate results. Well,
almost, as handling of decimals beyond a particular precision is tough. Nevertheless, it works
wonders.
• Communication: This has become the most important use of computers lately as communication
via computers is effective and efficient.
In this chapter, we will discuss the components of a computer and understand their nitty-gritty.
This is followed by the definition of software and hardware, and an informed discussion on the types of
software. This chapter has been organized as follows (Figure 1.1):
1.2 Fundamentals
1.3 Hardware
1.4 Software
1.6 Memory
1.9 Conclusion
1.2 FUNDAMENTALS
A computer stores and manipulates data, it runs various software and greatly helps in communication.
Note that the word computer refers to not just a desktop or laptop it practically refers to all the computing
devices. Though this word is generally associated with a machine that you work on, the electronic device
that you use including AC, gaming consoles, etc. also have embedded computers. This section explores the
word computer and briefly explains its architecture.
A computer has a processor, input-output units, and memory unit. Your computer (desktop/ laptop)
can run many application programs. The allocation of resources and their governance is handled by an
Operating System. You can write output in a word processor application, store the details of any financial
transactions using a spreadsheet application, listen to the music in a media player application, and design
amazing applications in python using Jupyter. These all are examples of Application programs.
The electronic devices have embedded computers, which accomplish specific tasks. That is, general-
purpose tasks are not required from such devices and hence they may or may not have an Operating
System. It is often implemented using a chip or an IC, unless highly specific, complex tasks are required.
Most of the readers must be aware of the difference between Hardware and Software. The following
table (Table 1.1) revisits the points already known to most of you.
Hardware Software
Computer hardware is the physical component of Software is a set of instructions
a computer. It includes everything we can see and
touch.
Hardware is a physical device, but we cannot touch It is developed and needs hardware to execute,
a software. and we can also transfer software.
Examples: Keyboard, Mouse, Monitor, Printer, Examples: MS Word, Excel, PowerPoint, etc.
CPU, Hard disk, etc.
1.3 HARDWARE
Having studied the fundamentals, let us now turn our focus to Hardware.
1.3.1 Input Devices
A computer takes an input, processes it and gives some output. The input is given using devices referred
to as input devices. That is, an input device provides data to the computer. As stated earlier, input devices
include the keyboard, mouse, joystick, microphone, card reader, touchpad etc.
1.3.1.1 Keyboard
The keyboard is one of the most important input devices. It has all the keys which an electronic typewriter
had, along with some more keys. It generally has buttons for numbers, characters, special symbols,
functions and controls. Moreover, there are many types of keyboards for special purposes like a Gaming
Keyboard, multimedia keyboard etc. Figure 1.2 shows a standard keyboard.
Keyboards can also be classified as serial or parallel. A serial keyboard is one that sends one bit at a
time and the parallel keyboards are one that can send a few bits in parallel. That is, they have more than
one data line.
A keyboard generates a code for the key pressed and sends it to the computer. It may be noted that
the code is sent only if the key is pressed for more than a certain duration. The typematic rate determines
this speed.
1.3.1.2 Joysticks
A Joystick is used in gaming. It is like a toggle button. The movement of a stick in the
joystick is mapped with the system being used. The moment of the stick is gauged
by a potentiometer inside it. Generally, a Joystick can be rotated in clockwise and
anticlockwise directions also. Figure 1.4 shows a Joystick.
1.3.2 Output Devices Figure 1.4: A Joystick
As stated earlier, the computer takes an input and produces an output.
The output needs to be seen and hence an output device is needed. We
can generally see the output on the Visual display Unit or the VDU, which
is connected to the computer (Figure 1.5). The VDU has been discussed
later in this chapter. Another important output device called printer has
been discussed as follows.
1.3.2.1 Printer
At times we also need a Hard Figure 1.5: Visual Display Unit
Copy of the output, for which
printer is needed (Figure 1.6). The printers can be classified
as impact or non-impact printers. Impact printers press the
element on the inked ribbon and work in a similar fashion as a
typewriter. They can be further classified as a line or character
printer. Figure 1.7 shows the classification of printers.
Figure 1.6: Printer
Impact Non-Impact
Dot-Matrix
A line printer produces one line at a time, and it has a row of hammers. Historically they are classified
as chain printers or drum printers. A character printer prints one character at a time. The Dot-Matrix
Printer is a type of character printer. The printer contains an array of pins and an inked ribbon. However,
the print quality of this printer is not very good. The wireless printers hit the market recently. These, owing
to the ease of use, have become very popular. The software is available for mobile phones, helping in
taking the printout and managing the printer from a distance.
1.4 SOFTWARE
The set of instructions given to the computer to accomplish the task is called software. Software processes
data with the help of hardware. Note that in order to accomplish the task, we write a set of instructions
and then implement them in a programming language. Everything from the application that you use to
the operating system is software.
Examples of application software include Microsoft Excel, which is a spreadsheet, Microsoft PowerPoint,
for making presentations etc. Examples of operating systems include Windows, Linux, Mac etc.
The computer hardware acts as per instructions given by the software. The software can be
categorized into the following categories.
• Application software: These software performs specific tasks. The examples of application
software include Google Chrome, which is a browser that helps us to interact with the internet.
Likewise, MS Paint helps us to draw and save figures. These software manage the information,
process data, store and organize data, construct visuals etc. They can be categorized as general
purpose and custom software.
• The general-purpose software: These software are meant for a larger audience and serves a
general-purpose. They are generally ready-made and perform the most common tasks. Some
examples of general-purpose software include Microsoft Access, which is used as a relational
database management system; Media Player which is used for viewing the video and listening
to the audio.
• Customer software: Imagine that you have started an emporium. You need to manage the
inventory and generate invoices, keep track of your staff etc. For this purpose, you consult a
software developer for developing a software that can accomplish that task and also generate
Application Software
System Software
A program written in languages like C, C++ etc. are compiled first. This compiled code gets loaded
into the memory and the processor executes it (Figure 1.10).
Linking and
Source Code Compilation Execution
Loading
Tokenization
Parser
Optimization
Operating
System
An operating system is expected to be robust, that is, it should handle various inputs without errors.
However, if an error occurs, it should be able to come out of it. It should be powerful, efficient, and
effective. They are complex programs and many take many persons to build in many years. Examples of
Operating system are as follows:
• MS-Windows.
• Ubuntu.
• Mac OS.
• Fedora.
• Solaris.
• Chrome OS.
Computer Computer
System System IOC IOC
CPU
I/O Device I/O Device
Hardware Memory
Basic
Components
Figure 1.17: Basic Computer
System: A Computer System
Power
Supply contains CPU, Memory, Input
Output Controller and Input/
Figure 1.16: Components of Output Devices, connected via
Computer System Buses.
It may be noted that the above figure is very simplified. A Computer System may not just have a single
CPU, there can be many cores. Moreover, there can be many types of CPU’s like a Graphical Processing
Unit (GPU), Tensor Processing Unit (TPU) and so on. The system can have many types of memories like
Main memory, cache and secondary memory.
The input devices include Keyboard, mouse, joystick, microphone, card reader, touch pad etc. The
output devices include screen, printer, speaker etc. The storage devices include disk drives etc. There are
many types of memories as well. These include main memory, cache, secondary memory etc.
1.5.1 Bus
The wires connecting various units of a computer are referred to as buses. A physical group of data lines,
which take data from one point to another, is called a data bus. Some of the most important buses are as
follows.
Data-bus: A data-bus carries data and has some width. For example, an eight-bit data bus carries
eight bits at a time.
Address-bus: The address-bus carries addresses, and
Control-bus: The control bus carries information related to an instruction.
1.5.2 Central Processing Unit (CPU)
The processor of a computer is like its brain. It is an electronic device that can manipulate information
using a set of instructions called Machine Code. The instructions entered by the user are converted to
Machine Instructions. These instructions may be altered and hence make a computer programmable.
NOTE
The different processors have different instruction sets, and the program that we write gets
converted into the corresponding instruction sets.
A processor processes information and generates output. The input is given by input devices. The
output is conveyed to the user using the output device. Memory is required to store the intermediate
instruction or temporary result.
1.6 MEMORY
Memory is a one-dimensional array of locations that store data. Memory can be classified into the
following types:
• Register: They are the fastest memory and are conceptually nearest to the process. A processor
may use it for its internal working.
• Cache: The most frequently accessed data is stored in cache for efficient and effective processing.
• Main memory: Main memory consists of mainly RAM chips. It is a place where data and
instructions are stored so that they can be accessed by the computer.
• Hard disk: Hard disk is a device, which stores all our data and programs. It is generally an
electromagnetic device consisting of magnetic plates, and a read-write head. They can store a
huge amount of data.
Data units of memory are as follows:
• Bit: A bit is single ‘0’ and ‘1’.
• Bytes: A byte contains 8 bits.
• Kilobytes: A KB contains 1024 bytes.
• Megabytes: A MB contains 1024 KB.
• Gigabytes: A GB contains 1024 MB.
• Terabytes: A TB contains 1024 GB.
• Petabytes: A PB contains 1024 TB.
Computer memory can be classified as primary memory and secondary memory. The CPU can directly
access the primary memory whereas the secondary memory cannot be directly accessed by the CPU. Note
that the main memory of the device is primary memory whereas the data is permanently stored in the
secondary memory. Further, the classification of primary memory is RAM and ROM.
We hear a lot about RAM while gaming or working with heavy Software. The ROM, on the other
hand, stores the bootstrap program and is non-volatile. The following table (Table 1.3) distinguishes
between RAM and ROM.
Table 1.3: Difference between RAM and ROM
RAM ROM
Random Access Memory (RAM) is a read and Read-only Memory (ROM), as the name suggests,
write memory. is a Read-Only Memory.
It is volatile. It is non-volatile.
EPROM
(Erasable Programmable ROM)
Can also be erased
programmatically
ROM
EEPROM (Electrically Erasable
Programmable ROM)
This can be erased using
electrical pulses
Flash EEPROM
It is faster than EEPROM
1.9 CONCLUSION
This chapter introduced computer organization. The components of a digital system have been explained
in the chapter, along with a brief introduction to input-output devices. The chapter also discussed types
of memories and their importance. Finally, the steps in program execution have been introduced in this
chapter. These are the basic building blocks of Computer Science. The reader is expected to visit the links
given in the Appendix of this book to get an insight into all the components explained in this chapter. The
following chapters introduce number systems, Boolean algebra, logic gates etc., which will help the reader
to get insight into the working of a digital system. Let us now hit the questions!
THEORY
1. Explain memory hierarchy.
2. What is the difference between RAM and ROM?
3. Explain the importance of cache.
4. What is a computer register?
5. Explain the organization of a digital computer.
6. Name and explain the functioning of any two input devices.