0% found this document useful (0 votes)
33 views36 pages

Computer Science: Python

Uploaded by

jeet.kxj86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views36 pages

Computer Science: Python

Uploaded by

jeet.kxj86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

2 ND

NEW AGE As per the


New Syllabus
of
EDITION
CBSE
TEXTBOOK Code No. 083

OF

COMPUTER SCIENCE
WITH

PYTHON
CLASS XI INCLUDES
FR
EE

PRACTICAL
WORKBOOK

ü Computer System and Organisation

ü Computational Thinking and Programming-1

ü Society, Law and Ethics

HARSH BHASIN
TEXTBOOK
OF

COMPUTER SCIENCE
WITH

PYTHON
CLASS XI

SECOND

EDITION

As per the New Syllabus of CBSE


(Code No. 083)

DR. HARSH BHASIN


Assistant Professor
Manav Rachna University
Faridabad, Haryana
Copyright © 2022, 2020, New Age International (P) Ltd., Publishers
Published by New Age International (P) Ltd., Publishers
First Edition: 2020
Second Multi Colour Edition: 2022

All rights reserved.


No part of this book may be reproduced in any form, by photostat, microfilm, xerography, or any other means,
or incorporated into any information retrieval system, electronic or mechanical, without the written permission
of the publisher.
GLOBAL OFFICES
• New Delhi NEW AGE INTERNATIONAL (P) LIMITED, PUBLISHERS
7/30 A, Daryaganj, New Delhi-110002, (INDIA), Tel.: (011) 23253472, 23253771, Mob.: 9315905300
E-mail: [email protected] • Visit us at www.newagepublishers.com

• London NEW AGE INTERNATIONAL (UK) LTD.


27 Old Gloucester Street, London, WC1N 3AX, UK
E-mail: [email protected] • Visit us at www.newacademicscience.co.uk

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]

• Cochin CC-39/1016, Carrier Station Road, Ernakulam South, Cochin-682 016


Tel.: (0484) 4051304, Mob.: 9315905289, 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]

C-22-06-13230 PRICE OF THIS BOOK INCLUDES FREE WORKBOOK

Printed in India at Ajit Printing Press, Delhi.


Typeset at Little Bird, Delhi.

NEW AGE INTERNATIONAL (P) LIMITED, PUBLISHERS


7/30 A, Daryaganj, New Delhi-110002
Visit us at www.newagepublishers.com
(CIN: U74899DL1966PTC004618)
Preface
Python is a robust Procedural, Object Oriented and a Functional language. The features of the language
make it tremendously valuable for web development, gaming, and scientific programming. Lately the
language has become incredibly popular. The popularity of the language can be gauged from the fact that
it is currently being used by Google, YouTube, Bit Torrent and many other giants.
This book primary deals with problem solving and programming in Python. Programming is the soul
of Computer Science and designing of a program requires an involved knowhow of the paradigms along
with the ability to use the standard procedures. So, in order to become a virtuous programmer one
must not only learn the syntax of the language but also develop an ability to apply the concepts learned
to solve the problems. It may be stated here that the programming languages and their syntax that a
professional learns are of no use until the algorithms that are to be implemented are well designed. So, a
basic knowledge of Algorithms and Complexity is also essential. This is the reason that these topics have
also been included in this book.
In the next class you will study about data connectivity, and hence an introduction to Database
Management System has also been included in the book. This book also includes an introduction to SQL.
One of the most important goals of this book is to make the readers understand Python’s discriminative
features. This book also includes an introduction to Cyber Safety and issues related to social media.
The Python programs are available at www.newagepublishers.com
These following steps will help you to access the program files:
1. Go to http://www.newagepublishers.com
2. On the right top, go to search and enter the author’s name or title (Python).
3. Find and open the book link or click at the link below:
www.newagepublishers.com/servlet/nagetbiblio?bno=3216
OR

Scan the QR code

4. Under 'About the Book' click at supplementary data.


Dr. Harsh Bhasin

(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

Appendix : Answers to Multiple Choice Questions 323


Bibliography 325
Index 327

(xviii)
Basic Computer
1 Organization

After reading this chapter the reader will be able to


• Understand the importance and features of Computers
• Differentiate between Software and Hardware
• Understand some important Hardware devices and the types of Software
• Classify Software into system and application software
• Understand the terms: Data, Process and Booting
• Understand the roles of a compiler, an interpreter and an assembler
• Differentiate between a compiler and an interpreter
• Understand the roles of system utilities
• Understand Computer System Architecture
• Understand the types and components of a processor
• Understand Memory Hierarchy
• Understand the types of RAM and ROM

1.1 INTRODUCTION TO COMPUTER SYSTEM


“The digital revolution is far more significant than the invention of writing or even of printing.” 
 –Douglas Engelbart
Let us start our discussion with the need and the importance of studying Computer Science, followed
by the definition of the term computer. Have you noticed that computers are everywhere, in some form
or the other, from your home to your workplace, from the grocery shop to the mail, and so on? You must,
therefore, understand the term computer and should be able to appreciate its uses.
So, what is a computer? It is an “Electronic machine which operates under the control of instructions
stored in its own memory.” A computer accepts an input, processes it, and produces the result. It may also
store the result.
Let’s spare a moment to understand why computers are so powerful. Some of the reasons for this
include the following:
• Storage: Computers provide us with ample storage, which not only helps us to save the data but
also manages and organizes it.

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.5 Computer System Architecture

1.6 Memory

1.7 Stored Program Concept

1.8 Programming Tools

1.9 Conclusion

Figure 1.1: Organization of this chapter

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.

4 Computer Science with Python–XI


Table 1.1: Differences between Hardware and Software

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.

Figure 1.2: Standard keyboard

A keyboard has many layouts some of them are as follows


• QWERTY • AZERTY
• QWERTZ • DVORAK
The last is generally used by French-speaking people. Moreover, we now have keyboards that support
Indian languages as well.
A Laptop has a standard QWERTY keyboard, with a lesser number of keys. In a laptop, many keys
perform more than one task. The Gaming keyboards are specially designed for the ease of gamers. We

Basic Computer Organization 5


also have thumb-sized keyboards, generally used in handheld devices. The foldable keyboards are also
available.
The on-screen keyboard of Windows is shown in Figure 1.3.

Figure 1.3: On-Screen 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

6 Computer Science with Python–XI


Printers

Impact Non-Impact

Line Character Laser

Dot-Matrix

Figure 1.7: Classification of printers

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

Basic Computer Organization 7


the invoices in a particular format. Such software which caters to the specific need of the
customer and is developed especially for the customers are called customer software.
The software can also be classified as open-source and proprietary. Software that provides a whole
source code to the public is free software. This is done to improve the quality of the software (FOSS). The
example of FOSS includes some distributions of Linux, Google chrome, Anaconda etc.
For some Software, the purchase is required before using them. Such software is called proprietary
software. The examples include MATLAB etc. In between these two, there is a third category. This category
includes the software where source code is not available, but they are free and called freeware.
1.4.1 Data
Everything that we store in a computer from the result of our experiments to the text to our reports; from
the mp3 of the songs that we like to the videos that may go viral; from the pictures of our parties to the
drawings that we make, is Data.
The computer manipulates data. When we open the word file, data is displayed; when we click on
an mp3 file, we can listen to a song; when we send a huge chunk of files to a friend by compressing, we
manipulate the data. So, effectively we store and manipulate data using computers. To store data we need
memory, to process it the processor of the computer along with main memory is required, and the output
is produced using the output devices.
1.4.2 Booting
When we put on the computer some programs are executed; this is required for initial configuration and
correct operations. After this, we may run some software for which the operating system is required. Note
that the initial program is permanently stored in the memory this software is called firmware.
The boot loader reads the operating system from the disk and positions it appropriately in the
memory, so that the processor may run them. The application software, as stated earlier, is controlled by
the Operating System. They need input for which they use input devices. To interact with the input devices
device drivers are used. They may store some data in the disk and for execution, they need main memory
and cache.
Effectively, at the top application software run, and below the application software everything is
system software (Figure 1.8).

Application Software

System Software

Figure 1.8: Application and System Software

1.4.3 Language Translators


A translator converts code written in one language to that in the other language. The input language is
called the source code and the output is referred to as the target code. If the source code is a high-level
language (HLL) and the target code is the Machine Level Language (MLL) or assembly language, then the
translator is called the compiler. If the source code is an Assembly Level language and the target code is
the Machine Level Language (MLL) or assembly language, then the translator is called the Assembler. An
interpreter, on the other hand, does not compile the instructions but directly executes them. Figure 1.9
shows the different types of translators.

8 Computer Science with Python–XI


Translator

Compiler Interpreter Assembler

Figure 1.9: Types of translators

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

Figure 1.10: Program execution

1.4.4 Compiler and Interpreter


A compiler converts the source code into the object code or intermediate code. It performs the following
tasks.
• Converts the program into smaller parts called tokens
• Checks if the syntax is correct
• Checks the semantics
• Produces an intermediate code
• Optimizes the intermediate code
• Produces the final Object code
1.4.1.1 Working of a compiler
The compiler works as follows. We write a program and compile it. The program is first converted into
smaller units called tokens. This is done in the Lexical Analysis phase of the compiler. The machines
called Finite Acceptors are used for accomplishing this task. This is followed by checking the instructions
with respect to the Grammar of the language. This task is accomplished in the parsing phase. This phase
also performs the semantic analysis. This is followed by the Intermediate Code Generation. The code is
then optimized for performance and finally, the Object Code is generated. The process is shown in the
following Figure 1.11. It may be stated here that writing a compiler is a difficult task. The first compiler of
FORTRAN took 18 man-years to complete.

Basic Computer Organization 9


Lexical Analyser

Tokenization

Parser

Syntactic Analysis Semantic Analysis

Intermediate Code Generator

Intermediate Code Generation

Optimization

Produces Optimized Code

Object Code Generator

Produces Object Code

Figure 1.11: Phases of compiler and their functions

1.4.1.2 Portability and intermediate code


It may also be noted that not all the compilers convert the code into Object code; some may also produce
an intermediate code. This is done to achieve portability. For example, a JAVA compiler converts the
source code into Bytecode. The Bytecode so produced is converted into the Machine Code using Java
Virtual Machine. So, if you write a JAVA code and compile it, you get a Bytecode. Likewise, C# ’s compiler
converts the source code to the Microsoft Intermediate Language (MSIL).
1.4.1.3 Interpreter
The instructions written in scripting languages need not to be compiled into the object code. They are
executed by what is referred to as the interpreter. The interpreter may parse the code to access its
behaviour. The interpreters of LISP are examples of such types. It may convert the code into an intermediate
representation. This is done in Python. The interpreter can also execute the precompiled code e.g. The
PASCAL compiler.
Based on the above concepts, computer languages can be classified as interpreted or compiled. The
languages like C, C++ etc. are compiled languages and are converted into object code.
1.4.5 Assembler
The assembler converts the assembly-level language into machine code. An assembler is quite different
from a compiler, both in terms of performance (as an assembler is faster) and in terms of the job done.
Some of the assemblers may perform slightly complicated tasks like optimizations. The assemblers can be
classified as one-pass and multi-pass assemblers. In the latter, a table of symbols is created which is then
used to generate a code.
1.4.6 Linker and Loader
A program may use pre-defined functions, defined in modules in some packages. The source file, in such
cases, makes sense only if the corresponding library files are interpretable. For this task, the linker comes

10 Computer Science with Python–XI


to our rescue. The task of a linker is to take one or more files, generated by the compiler and crafts a single
executable file
As stated earlier, the loader also prepares the program for execution by loading the programs
and libraries in the Main memory. The loader, generally, reads the contents of the executable file and
accomplishes various preparatory tasks. The control is then passed on to the Operating System which asks
the processor to execute the task.
It may be noted that not all the systems have loaders. The embedded systems, for example, do not
have loaders and the code executes from the Read-Only Memory (ROM) itself.
1.4.7 System Software and System Utilities
System software are designed to control the operation and extend the processing functionalities of a
computer system. System software makes the operation of a computer more fast, effective, and secure.
The software that control and manage the computer hardware are broadly referred to as System
Software. Note that the software can be classified a application and system software. The former have
already been discussed in the chapter. The later helps the application program to run correctly.
The System Software
• Control the operations
• Makes the operation of a
computer faster, effective, and
secure.
Examples of System Software
include Operating system, Communication
software, etc.
Software utilities are software that
analyses or helps in the maintenance of a
computer system. Some of the important
utility software are as follows:
• Antivirus
• Compression
Figure 1.12: Norton Antivirus
• Disk management
• Disk defragmenter
Antivirus (as per https://us.norton.com/internetsecurity-malware-what-is-antivirus.html). “Antivirus
software helps protect your computer against malware and cybercriminals. Antivirus software looks at
data — web pages, files, software, applications — travelling over the network to your devices. It searches
for known threats and monitors the behaviour of all programs, flagging suspicious behaviour. It seeks to
block or remove malware as quickly as possible.”
Compression (as per https://docs.microsoft.com/en-us/windows/win32/fileio/file-compression-
and-decompression). “Zipped (compressed) files take up less storage space and can be transferred to
other computers more quickly than uncompressed files. In Windows, you work with zipped files and
folders in the same way that you work with uncompressed files and folders. Combine several files into a
single zipped folder to more easily share a group of files.”

Basic Computer Organization 11


Figure 1.13: 7 Zip

Disk management (as per https://docs.microsoft.com/en-us/windows-server/storage/disk-


management/overview-of-disk-management).
“Disk Management is a system utility in Windows that enables you to perform advanced storage
tasks. Here are some of the things Disk Management is good for:
• To set up a new drive.
• To extend a volume into space that’s not already part of a volume on the same drive.
• To shrink a partition, usually so that you can extend a neighbouring partition.
• To change a drive letter or assign a new drive letter.”

Figure 1.14: Disk Management in Windows

12 Computer Science with Python–XI


Disk defragmenter (as per https://support.microsoft.com/en-us/windows/ways-to-improve-your-
computer-s-performance-c6018c78-0edd-a71a-7040-02267d68ea90). “Fragmentation makes your hard
disk do extra work that can slow down your computer. Removable storage devices such as USB flash drives
can also become fragmented. Disk Defragmenter in Windows rearranges fragmented data so your disks
and drives can work more efficiently. Disk Defragmenter runs on a schedule, but you can also analyze and
defragment your disks and drives manually.”

Figure 1.15: Disk Defragmenter

1.4.8 Device Drivers


Hardware devices are needed by a software application to accomplish the desired task. That is, they
need to communicate with the hardware. This communication is done using the device drivers. They are
essential and act as an interface between the hardware and the application which intends to use that
hardware.

Basic Computer Organization 13


It may also be noted that the device drivers depend on the operating system we use. There are many
types of device drivers which may work in kernel or user mode.
1.4.9 Operating Systems
A government of a country is entrusted with the responsibility of allocating resources in a judicious way.
A Computer System also has many resources e.g. the CPU, disk, memory etc. The processor uses these
resources. At times the processes compete for these resources. The operating system acts like a resource
allocator, it handles the allocations of the resources and de-allocating them.
The operating system also behaves as an underline machine, which simulates other machines. In
addition to these it handles multiple users, if required and deals with multiple processes. It basically
provides services. It helps us to interact with hardware and an environment which is easy to use.

Operating
System

Resource Virtual User


Allocator Machine Interface

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.

1.5 COMPUTER SYSTEM ARCHITECTURE


A Computer System consists of a large number of components. These components are arranged in layers,
owing to many reasons one of which is manageability. The components can further be classified into
hardware and software. The hardware components are the system containing the Central processing Unit
(CPU), memory, basic elements and power supply, among other things. The Software components of a
system include the Application Programs, utilities, Operating System and Basic Input Output system (BIOS),
to name a few. Figure 1.16 summarizes the discussion. Figure 1.17 shows the basic Computer System.

14 Computer Science with Python–XI


Application
Programs Memory
CPU
Utilities
Software
Operating
System
BUS
BIOS

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.

Basic Computer Organization 15


A processor is usually implemented in a single chip or an Integrated Chip (IC), which is called a
microprocessor. Some of the examples of microprocessors are the following (Table 1.2).
Table 1.2: Some of the examples of microprocessors

Name of the Microprocessor Number of bits processed in Year


a unit time
4040 4 bits 1974
8085 8 bits 1976
8080 8 bits 1974
8008 8 bits Mid 1972
P1 32 bits 1993
P2 32 bits 1997
P3 32 bits 1999
P4 64 bits 2000

Difference between a microcontroller and a microprocessor


A microcontroller is a processor used in an embedded system. They are used in all electronic devices and
generally have their own chip. Some of the prominent examples of microcontrollers are Intel 8051, ARM
Cortex-M series.
A microcontroller has a small amount of memory and may act as a minicomputer. It generally doesn’t
require external RAM’s etc. and is generally implemented as a chip that does a very specific task for
example in our washing machine and ovens, we generally have microcontrollers.
Note that we generally do not expect general-purpose tasks to be done by a microcontroller.
The microprocessor on the other hand is an essential component of any computer system and can be
considered as the brain of the computer. They are used in systems from which we expect general-purpose
tasks.
As stated earlier, a processor is to the computer system as the brain is to the body. It can perform
the following operations:
• Write data to the memory • Read data from IO devices
• Write data to the IO devices • Read instructions from the memory
• Read data from the memory • Carry out processing
The various components of a processor are discussed in the following sub-sections:
1.5.3 Arithmetic Logic Unit (ALU)
Arithmetic and Logic Unit execute the corresponding instructions. This unit can perform operations like:
• Addition • OR
• Subtraction • Not
• Multiplication • Rotate
• Division • Shift, and
• AND

16 Computer Science with Python–XI


1.5.4 Control Unit
A program consists of instructions. Effectively, the execution of these instructions helps us to accomplish
the desired task. Each instruction when executed needs to be fetched from the main memory and directed
to the instruction register of the CPU, based on its content. This task is done by the control unit. The Control
Unit receives input and directs the control signal to the CPU. This part of the computer is responsible for
telling the hardware what to do.
The results are placed in the memory location and registers along with this the status of the previous
instructions are also stored.

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.

Basic Computer Organization 17


The data in a RAM is retained till the computer The data in a ROM is retained even after the
is on. computer is turned off.
RAM is faster. ROM is slower than RAM.
RAM is costly. The ROM is cheaper as compared to RAM.
Examples: SRAM, DRAM. Examples: PROM, EPROM, EEPROM.

1.6.1 Various Types of ROM


Figure 1.18 shows various types of ROMs.

PROM (Programmable ROM)


Can be re-written
programmatically

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

Figure 1.18: Types of ROM

1.6.2 Various Types of RAM


RAM can be classified as follows:
• Static RAM: It is volatile as it retains data only for the time while the power is on. If the
technology used in the creation of SRAM is CMOS, then the access time will be 10-100 ns, the
RAM is generally organised as a matrix internally.
• Dynamic RAM: It is also volatile and always uses a matrix architecture, but it needs to be
periodically refreshed vis-à-vis SRAM also it is faster than SRAM.
1.6.3 Primary Memory and Secondary Memory
The secondary memory can be mass storage devices like a Hard Disk and various types of drives. Secondary
memory includes the following:
1. USB Drives 2. SSD (Solid State Drives)
3. Optical Drives 4. Magnetic Tapes

18 Computer Science with Python–XI


Primary Memory Vs. Secondary Memory

Primary Memory Secondary Memory


The Primary Memory, RAM is temporary. The Secondary Memory is permanent.
The CPU can directly access the Primary Memory. The CPU cannot directly access the Secondary
Memory.
Primary Memory is the main memory. Secondary Memory is the auxiliary memory.
Primary Memory is expensive but faster. Secondary Memory is relatively cheap but slower.
Examples: RAM, ROM, and Cache. Examples: USB Drives, SSD, and Magnetic Tapes.

1.6.4 Cache Memory


Cache is the type of memory that stores data for future use in
order to make the process faster. The data stored in a cache is HDD L
generally that which was used in some earlier computation. It a
is faster than the main memory but slower than the hard disk. r
Generally, in a computer, a hard disk has a very large storage E g
Main x e
capacity may be in TB’s. The main memory is relatively small as F
Memory p r
in a few GB’s but is faster. The cache has lesser storage capacity a e
s C
as compared to RAM but is faster and costlier than the RAM. t n
s a
It may be noted that the registers are the fastest memory e i p
available in the computer system and may be considered as r Cache v a
the most expensive. In terms of size, memory may be viewed e c
as shown in Figure 1.19. i
t
If the required data is found in the cache it is called Registers y
cache hit otherwise it is called cache miss so therefore most
frequently used data is stored in cache.
Figure 1.19: Memory Hierarchy
1.6.5 Hard Disk Drive
Hard Disk is a data storage device which is non-volatile and has a high storage capacity. In a hard disk, the
data is stored in digital form on one or more speedily rotating disks, which are called platters. The storage
is done using Magnetic Storage Techniques. This type of storage uses two types of magnetic polarities to
represent the binary information consisting of zeros and ones.
1.6.5.1 Components
A Hard disk has four major components (Figure 1.20) namely Platters, Spindle, Read/Write arm and
an Actuator. A brief explanation of the components is as follows.
• Platters: Platters are thin circular disks made up of aluminium, glass or ceramic. They have a
magnetic surface for storing the data. Generally, the platters are stacked to expand storage
capacity. The data is stored in tracks, sectors, and cylinders on each platter to keep it serene.
This also facilitates the search. Tracks are concentric circles where the data is stored whereas
sectors are sections within each track and each of these sections is the smallest physical storage
unit on a disk.
• The Spindle: The spindle is a shaft, responsible for rotating the platters and keeping them a fixed
distance apart for the read and write arm to gain access to both sides of the platter.

Basic Computer Organization 19


• The Read/Write Arm: The read/write arm
controls the movement of the read/write
heads. The read and write heads physically
read and record magnetic patterns stored on
the platter and are situated a few microns
away from the platters. These heads are
controlled by the actuator arm based on the
data to be stored or accessed on the Hard
Disk.
• Actuator: The actuator is an electronic device
controlled by a small motor that guides the Figure 1.20: Hard Disk
movement of the head arm assembly.
• Except for the above there are some other components including
o The Printed Circuit Board (PCB),
o device case,
o data connector etc.
These control the data request from the hard disk. The device case holds the components
together and protects them from shocks.

1.7 STORED PROGRAM CONCEPT


In a computer system, both the instructions that manipulate the data and the data, which is manipulated
are stored in the same memory. Technically both instructions and the data stored in a computer may
be considered indistinguishable in the absence of a proper organization. Again, note that the data and
instructions are stored in the same memory where the memory is a linear array of locations, each location
has an address.

1.8 PROGRAMMING TOOLS


A programming tool helps in the development of software by accomplishing a program-specific task. It
may also be perceived as a software development tool. Examples include compiler, linker, assembler,
editors etc. The compilers, linkers and editors are explained in the following sections whereas one of the
editors is explained in section 7.4. This editor would henceforth be used for Python programming.

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!

20 Computer Science with Python–XI


Points to Remember
 A translator converts code written in one language to that in the other language. The input
language is called the source code and the output is referred to as the target code.
 If the source code of the translator is a high-level language (HLL) and the target code is the
Machine Level Language (MLL) or assembly language then the translator is called the compiler.
 If the source code of a translator is an Assembly Level Language and the target code is the
Machine Level Language (MLL) or assembly language, then the translator is called the Assembler.
 Lexical Analyzer: This is the first phase of the compiler. In this phase, the program is converted
into smaller units called tokens.
 Parsing: This is the second phase of the compiler. In this phase, the instructions are checked with
respect to the Grammar of the language. This phase also performs the semantic analysis.
 The intermediate code is produced by the Intermediate Code Generation phase of the compiler.
 The code is then optimized for performance and finally, the Object Code is generated.
 A JAVA compiler converts the source code into Bytecode.
 C# ‘s compiler converts the source code to the Microsoft Intermediate Language (MSIL).
 The instructions written in scripting languages need not be compiled into the object code. They
are executed by what is referred to as the interpreter.
 The task of a linker is to take one or more files, generated by the compiler and crafts a single
executable file.
 The loader prepares the program for execution by loading the programs and libraries in the Main
memory.
 The embedded systems do not have loaders and the code executes from the Read-Only Memory
(ROM) itself.
 When a program or a process executes, it resides in the Main memory.
 A cache is hardware capable of storing data so that future in order to fasten the future requests
for that data.
 The computer registers are quickly accessible location available to a computer’s central processing
unit (CPU).
 The typematic rate determines the speed of the keyboard.
 The allocation of resources and their governance is handled by the Operating System.
 A line printer produces one line at a time, and it has a row of hammers.
 A character printer prints one character at a time.
 The Dot-Matrix Printer is a type of character printer.
 To store data we need memory, to process it the processor of the computer along with main
memory is required, and the output is produced using the output devices.
 The boot loader reads the operating system from the disk and positions it appropriately in the
memory, so that the processor may run them.
 The application software is controlled by the Operating System.

Basic Computer Organization 21


VERY SHORT ANSWER QUESTIONS
1. While executing the program, the code resides in which memory?
Ans. RAM
2. Which memory stores the instructions that are most frequently executed?
Ans. Cache
3. Which memory stores the bootstrap process?
Ans. ROM
4. Which is the fastest memory in the computer?
Ans. Registers.
5. If you have 256 × 256 images, how much memory is required to store 1024 such images?
Ans. 1000 × 256 × 256 bytes = 64 MB
6. If you want to print a report, having artworks and designs, for official purpose, which printer would
you use?
Ans. Laser, if good quality prints are needed.
7. How is a C compiler different from a JAVA compiler?
Ans. The former produces object code and the later produces Bytecode.
8. Name a compiled language.
Ans. C
9. Name any two High Level Languages.
Ans. C#, Python
10. Name the steps in program execution.
Ans. Compilation > Linking > Loading > Execution

MULTIPLE CHOICE QUESTIONS


1. When a program executes, it must reside in
(a) RAM (b) ROM
(c) Server (d) None of the above
2. In which of the following the bootstrap resides?
(a) RAM (b) ROM
(c) Server (d) None of the above

22 Computer Science with Python–XI


3. Which of the following is volatile?
(a) RAM (b) ROM
(c) Both (d) None of the above
4. Which of the following stores instructions which executes frequently?
(a) Cache (b) Server
(c) Loader (d) None of the above
5. Which of the following is fastest?
(a) RAM (b) ROM
(c) Cache (d) Register
6. Which of the following is most expensive?
(a) RAM (b) ROM
(c) Cache (d) None of the above
7. Which of the following is slowest?
(a) RAM (b) ROM
(c) Cache (d) Hard disk
8. Which of the following are the types of ROM?
(a) PROM (b) EPROM
(c) Both (d) None of the above
9. Which of the following is not a type of mouse?
(a) Mechanical (b) Laser
(c) Chemical (d) None of the above
10. Which of the following is not a type of printer?
(a) Dot matrix (b) Laser
(c) Ink matrix (d) None of the above
11. Which of the following is not an input device?
(a) Mouse (b) Joystick
(c) VDU (d) None of the above
12. Which of the following is not an output device?
(a) VDU (b) Printer
(c) Scanner (d) None of the above
13. Which of the following is best, in terms of quality of printing?
(a) Dot Matrix (b) Laser
(c) Inkjet (d) None of the above
14. Which translator converts source code to object code?
(a) Compiler (b) Interpreter
(c) Assembler (d) None of the above
15. A complier produces
(a) Object code (b) Intermediate code
(c) Both (d) None of the above

Basic Computer Organization 23


16. A JAVA compiler produces
(a) Object code (b) Bytecode
(c) Both (d) None of the above
17. A C# compiler produces
(a) Object code (b) Microsoft Intermediate Language code
(c) Both (d) None of these
18. Which of the following loads the complied code in the memory?
(a) Loader (b) Linker
(c) Interpreter (d) All of the above
19. Which of the following produces a single executable file by clubbing the source code with the libraries?
(a) Loader (b) Linker
(c) Interpreter (d) All of the above
20. Which phase of compiler produces tokens?
(a) Lexical Analyzer (b) Parser
(c) Intermediate Code Generator (d) None of the above
21. Which phase of compiler produces parse trees?
(a) Lexical Analyzer (b) Parser
(c) Intermediate Code Generator (d) None of the above
22. Which phase of compiler produces optimized code?
(a) Lexical Analyzer (b) Parser
(c) Intermediate Code Generator (d) None of the above
23. Which of the following is a compiled language?
(a) C (b) C++
(c) Both (d) None of the above
24. Which of the following is an interpreted language?
(a) C (b) C++
(c) Python (d) None of the above
25. Do all systems have loaders?
(a) Yes (b) No
(c) Cannot say (d) None of the above

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.

24 Computer Science with Python–XI


7. Name and explain the functioning of any two output devices.
8. Differentiate between a dot-matrix and a laser printer.
9. Name any two types of mouse.
10. How does a keyboard work?
11. Name any two types of keyboards.
12. Who invented the mouse?
13. Who invented the printer?
14. Which company brought the first laser printer in the market?
15. What is a compiler?
16. What is an interpreter?
17. What is an assembler?
18. What is the function of a loader?
19. What is the function of a linker?
20. Explain the steps in program execution.
21. What are the various phases of a compiler?
22. Explain the task of each phase of a compiler.
23. Differentiate between compiler, interpreter and assembler.
24. Does each system has a loader? If not give an example of a system that does not have a loader.
25. Explain the difference between an assembler and interpreter.

Basic Computer Organization 25


Available at Your Nearest Booksellers

You might also like