RS3668 - Computer Science Grade 9 PDF
RS3668 - Computer Science Grade 9 PDF
Grade 9
Government of Nepal
Ministry of Education, Science and Technology
Curriculum Development Centre
Sanothimi, Bhaktapur
Computer Science
Grade 9
Government of Nepal
Ministry of Education, Science and Technology
Curriculum Development Centre
Sanothimi, Bhaktapur
2076
Publisher:
Government of Nepal
Ministry of Education, Science and Technology
Curriculum Development Centre
Sanothimi, Bhaktapur
© Publisher
Edition:
2076 BS (2020 AD)
Printing:
Janak Shikshya Samagri Kendra Limited
Sanothimi, Bhaktapur
Preface
The curriculum and curricular materials are developed and revised on a regular basis
with the aim of making education objective-oriented, practical, relevant and job oriented.
It is necessary to instill the feelings of nationalism, national integrity and democratic
spirit in students and equip them with morality, discipline and self-reliance, creativity
and thoughtfulness. It is essential to develop in them the linguistic and mathematical
skills, knowledge of science, information and communication technology, environment,
health and population and life skills. It is also necessary to bring in them the feeling of
preserving and promoting arts and aesthetics, humanistic norms, values and ideals. It
has become the need of the present time to make them aware of respect for ethnicity,
gender, disabilities, languages, religions, cultures, regional diversity, human rights and
social values so as to make them capable of playing the role of responsible citizens. This
textbook for grade nine students as an optional Computer Science has been developed
in line with the Secondary Level Optional Computer Science Curriculum, 2074 so as
to strengthen knowledge, Skills and competencies on computer literacy. It is finalized
by incorporating the recommendations and feedback obtained through workshops,
seminars and interaction programmes.
The textbook is written by Mr. Sunil Kumar Gharti, Mr. Sushil Upreti and Mr. Bimal
Thapa. In Bringing out the textbook in this form, the contribution of the Director General
of CDC Dr. Lekha Nath Poudel is highly acknowledged. Similarly, the contribution
of Prof. Dr. Shashidhar Ram Joshi, Dr. Dipendra Gurung, Ms. Pramila Bakhati,
Mr. Nabaraj Paudel, Mr. Jagadish Bhatta, Mr. Dibakar Durdarshi is also remarkable. The
content was edited by Mr. Yubraj Adhikari and Mr. Khil Narayan Shrestha. The language
of this book was edited by Mr. Shankar Adhikari and Mr. Nabin Kumar Khadka. The
layout of this book was designed by Mr. Khados Sunuwar. CDC extends sincere thanks
to all those who have contributed in developing this textbook.
Efforts have been made to make this textbook activity-oriented, interesting and learner
centered Curriculum Development Centre welcomes constructive feedback.
Introduction to Computer
The modern world is called the age of science and technology. We cannot imagine life
without science and technology. The modern world of advanced technology could not
have been established without the development of computer technology. There is rapid
development in computer. Computer is used in many different fields for varieties of tasks.
It is used all over the world, no matter whether a country it is developed, developing
or underdeveloped. Computer is also used in Nepal various fields like: business, bank,
education, entertainment, scientific research, law, airlines, traffic control, etc. So, the
computer is now affecting every sphere of human activities and leading to many changes.
It has brought enormous changes in the world.
Introduction
The word "Computer" is derived from the Latin word "Computare" which means
'to calculate'. Nowadays, computer has become an indispensable part of our life.
Computer is used in various places like: home, school, college, offices etc. Computer
can perform complex mathematical calculations accurately in a short period of time.
The modern computer has lots of capabilities like creating documents, videos, games,
music presentation, etc. It can use AI (Artificial Intelligence) for understanding natural
language, taking self-decision capabilities, analysing graphs and patterns, etc.
Information is organized or classified data, which has some meaningful results for the
receiver. Information is the processed data or meaningful results on which decisions
and actions are based.
Computer
Working Principle of a Computer
Computer is an electronic device that converts raw data into meaningful information
carrying out various processes as instructed by the programme. Every computer has
the ability to:
i. Automatic
A computer is an automatic device. It can do tasks automatically as instructed by
software. It can automatically control various devices attached with computer system.
Power of
Unit of Time Meaning Part of Second
10
Millisecond (ms) One thousandth of second 1/1000 10-3sec.
Microsecond(us) One millionth of second 1/1,000,000 10-6sec.
Nanosecond(ns) One billionth of second 1/1,000,000,000 10-9sec.
Picosecond (ps) One trillionth of second 1/1,000,000,000,000 10-12sec.
Femtosecond (fs) One quadrillionth of second 1/1,000,000,000,000,000 10-15sec.
iii. Accuracy
A computer performs t4asks accurately. If data and instructions given to the computer
are correct then it gives an accurate output. It means output totally depends on the given
instructions and input data. If input data is incorrect then the output will be incorrect
which is called GIGO (Garbage in Garbage out).
iv. Storage
Computer system consists of data storage unit. A computer has main storage and
secondary storage. A large amount of data can be stored in secondary storage like hard
disk, pen drive, CD/DVD, etc. for future use. The main memory (RAM) stores currently
used data. Computer stores data in term of 0 and 1. The different units of storage in
computer are given below:
vi. Versatile
A computer is a versatile device which means it is flexible. It has capability of performing
different types of tasks like drawing paints, playing games, music, calculations, sending
an e-mail, desktop publishing work, etc. in different field efficiently. So it is used in
different fields to perform varieties of tasks.
Application of Computer
A computer is given great importance in every field of work. Nowadays, it is impossible
to find where computer are not used. Computer and its technology are used in education,
agriculture, industries, banking, engineering, scientific research and many more. The
main applications of computer are described below:
i. Education
Nowadays, computer and Internet technology have changed the present education
system. Computer technology can be used for visual illustration like smart classroom
and distance learning education system. Today, school and colleges use computer in
computer lab and multimedia to teach students. A teacher can teach by using computer-
based presentations. Students can study various subject and complete assignment by
using Internet.
Computer in Communication
iii. Banking Sector
A computer has brought revolution in the banking sector. The different services like
accounting, customer records to update, bank statement etc. are performed by using
computer in banking sector. ATM (Automated Teller Machine) allows 24 hours banking
services to their customers so that they can withdraw money at any time.
iv. Medicine
A computer is used in scanning and diagnosing of various diseases through CT scan
(Computed Tomography scan), ultrasounds, ECG (Electro Cardio Graph) etc. It is also
used in hospitals to keep records of patients and medicines. Nowadays, computer is
used in surgery too. Doctors use computer and Internet services to provide telemedicine
services to remote areas of our country, Nepal.
Computer in Medicine
v. Entertainment
A computer is used to entertain people. It is used to play games, listen to music, watch
videos, movies and cartoon etc. It is used to watch online movies and play online games
6 Computer Science : Grade 9
by using Internet.
Computer in Entertainment
vi. Scientific Research
A computer is used in all types of scientific research. Scientists collect the latest
information by using internet all over the world. It is used in weather forecasting, space
research, complex research in various scientific fields etc.
Summary
The word "Computer" is derived from the Latin word "Computare" which means
to calculate.
A computer is an electronic device that accepts the raw data and instructions from
the user; processes raw data according to the given set of instructions, stores and
gives meaningful information.
The speed of computer is measured in MegaHertz (MHz) or GigaHertz (GHz).
A large amount of data is stored in secondary storage like hard disk, pen drive,
CD/DVD, etc. for future use.
Computer and its technology are used in education, medicine, banking sector,
entertainment, scientific research and agriculture.
Technical Terms
Computer : An electronic device that processes raw data to give information.
Input : Enter raw data and instruction into the computer.
Output : Display meaningful information from the computer.
Process : Computation according to given set of instructions to produce
required result.
8 Computer Science : Grade 9
Storage : Keeping data and information for future use.
GIGO : If inputted data is incorrect then output will be incorrect.
Byte : The combination of eight bits.
Exercises
1. Answer the following questions.
a) Define Computer and list its capabilities.
b) Write the limitations of computer.
c) What is GIGO?
d) Explain working principles of computer with block diagram.
e) List any four features of computer.
f) Why is computer called diligence machine?
g) Describe the use of computer in education field.
h) Mention any four uses of computer.
i) State different units of storage in computer.
Project Work
1. Draw a computer and its parts on a chart paper and display it in your classroom.
2. Divide a class into various groups and conduct a presentation on the following
topics:
a) Features of computer
b) Main application area of computer
3. During the course of a normal day, keep a list of your encounters with computer
of various kinds. Your list should include the and the time of the encounter, the
type of interaction you had with the technology and the result of the interaction.
Share your list with the class.
4. Conduct a speech competition on the topic 'Role of computer in education and
entertainment'.
Nowadays, various types of computer are available. These computers are different from
each other on the basis of their purpose, capacity, size, working principle, brand etc.
Computer can be categorized into three types according to the working principle (data
type they operate). They are:
i. Analog computer
ii. Digital computer
iii. Hybrid computer
On the basis of
working principle
On the basis of
On the basis of size
purpose
Mainframe
Micro computer Mini computer Super computer
computer
Classification of Computer
Analog computer
Digital Computer
Digital computers are general-purpose computers which solve problems by computing
discrete data. It works on digital values, binary digits (0 or 1). It can perform many tasks
according to user requirements. Computer in school, home and office are examples of
digital computer.
Digital Computer
On the basis of purpose, digital computers are classified into two types.
On the basis of size, digital computers are classified into four types. They are
i. Microcomputer
ii. Minicomputer
iii. Mainframe computer and
iv. Supercomputer
i. Microcomputer
Microcomputer is also called PC (Personal Computer) because it is used by a single
person at a time. Microprocessor is used as main processing unit (CPU). IBM-PC was
Desktop computer
Laptop computer
Palmtop computer
Notebook computer
Tablet computer
Notebook Computer
ii. Minicomputer
Minicomputer
Minicomputer is more powerful and expensive than microcomputer but less powerful and
costly than mainframe computer. So, the capabilities of a minicomputer are in between
microcomputer and mainframe computer. Minicomputer is used in scientific research,
banking system, telephone switch, etc. These computers work on multiprocessing
system and about two hundred of PCs can be connected to the network. PDI-1 was
the first minicomputer designed by DEC (Digital Equipment Crop) company in 1960.
Mainframe Computer
Mainframe computers are more powerful, have large storage capacity and more
expensive than minicomputer but less powerful and costly than supercomputer. These
computers allows multi-user and have multi-processor and support more than 200 PCs.
These computers are used as a server on WWW (World Wide Web) and also used in
large organizations such as a bank, telecommunication, airlines and universities for large
data processing. IBM is the major manufacturer of mainframe computer. IBM 1401
mainframe computer was brought to Nepal for the first time to process census data in
year. IBM-2 series, system 210 servers, CDC (Control Data Cyber) 6600 etc. are the
popular examples of mainframe computer.
iv. Supercomputer
Sunway Taihulight
Supercomputers are the most powerful, most expensive and have the highest processing
speed most than other computers. It has parallel processing for performing any task.
These computers are mainly used in weather forecasting, nuclear energy research,
national security, space-related research, etc.
Hybrid Computer
Hybrid Computer
The computer-designed with combined features of analog computer and the digital
computer is called a hybrid computer. These computers are designed for a special
purpose. They are used in hospital for Ultra Sound, ECG (Electro Cardio Graph), CT
scan (Computed Tomography scan), etc., in aeroplanes for air pressure, temperature,
speed, weight, in scientific lab, in ships, large industries etc.
Technical Terms
Analog computer : Measures continuously changing data such as pressure, temperature.
Digital computer : Solves problems by discrete data.
Minicomputer : More powerful and more expensive than a microcomputer.
Mainframe computer : More powerful and has large storage and more expensive than
minicomputer.
Super computer : The most powerful, the most has expensive and with the highest
processing speed than others.
Hybrid computer : A computer with the combination of features of both analog
computer and digital computer.
Project Work
1. Draw on a chart paper the types of computer on the basis of working principle
and paste in your classroom.
2. Collect some examples of analog, digital and hybrid computers.
3. Prepare a presentation about the use and purpose of hybrid and supercomputer in
different sectors and present to your class as a group work.
4. Divide a class into various groups and conduct a presentation on the following
topics:
a. Type of computer on the basis of purpose.
b. Type of computer on the basis of size.
c. Type of computer on the basis of work.
A combination of related units that have common purpose of achieving some objectives
is called a system. For example, there are different units in the hospital system like
doctor, nurse, surgery room, medical, etc.
Likewise, there are different units in computer system that work together to perform
varieties of tasks. So, computer system is a group of hardware and software which
work together to process data according to the instructions given by user to produce
information.
a. Data: Data is the main part of computer system. It can be processed to get desired
22 Computer Science : Grade 9
output as information.
b. Software: A set of programs are called software which instructs the hardware to
perform a task. For example MS Windows, MS Word, MS Excel, etc.
c. User: The person who operates computer system is called a user.
d. Hardware: The physical parts of a computer which can be touched, seen and felt
are called computer hardware. For example Keyboard, mouse, monitor, etc.
The computer hardware is further divided into four units:
a. Input unit
b. Process unit
c. Output unit and
d. Storage unit
a. Input Unit
This unit enters data into the computer. An input unit consists of input devices like
keyboard, mouse, microphone, joystick, etc. These devices are used to enter data and
instructions or commands into computer system. Input unit acts as a communication
channel between user and computer. The input devices translate the information into a
form understandable by the computer.
Input Device
b. Processing Unit
A processing unit consists of processing devices like CPU (Central Processing Unit).
CPU is the main processing unit of a computer system. It is also known as the brain of
computer system. It receives data from input unit, processes it as instructed by the user
and produces information as output.
= 1,000,000,000 Hz (Hertz).
So, one GigaHertz is equal to one billion hertz. The CPU speed of 2.1 GHz is equal to
2.1 *1,000,000,000 Hertz.
i. CU (Control Unit),
ii. ALU (Arithmetic Logic Unit) and
iii. MU (Memory Unit- Register Array)
i. Control Unit
Control Unit is a part of the CPU that controls and coordinates activities of other units
of computer system. It acts as a nervous system of computer. It controls the execution of
instructions given to system. It coordinates the flow of data in or out of ALU, memory
and various input or output devices.
Output devices
d. Storage Unit
A storage unit consists of primary and secondary storages. The primary storage or main
storage stores raw data and instruction. RAM (Random Access Memory) and ROM
(Read Only Memory) are the examples of storage unit.The functions of the storage
unit are below.
Storage devices
Technical Terms
Computer system : A combination of hardware and software to produce information.
Hardware : The physical parts of computer which can be touched, seen
and felt.
Software : A set of programs which instruct hardware to perform a task.
User : The person who operates a computer system.
Data : Raw facts or figures which do not have a clear meaning.
Input unit : To enter data and instructions or commands into the computer
system.
Processing unit : Processes raw data as instructed by the user and produce output.
Arithmetic unit : Performs arithmetic operation like addition, subtraction, etc.
Logic unit : Performs logical operations like equal to, greater than, less than,
etc.
Exercises
1. Answer the following questions.
a) What is the computer system?
b) Write down the main units of the computer system.
Project Work
1. Describe computer system and its main unit by using power point presentation
and demonstrate in your class as a group work.
2. Prepare a presentation about "CPU is also known as the brain of computer system"
and demonstrate in your class.
28 Computer Science : Grade 9
Unit 1.4
Computer Hardware
The physical parts of a computer which can be seen, felt and touched are called computer
hardware. Computer hardware is important component of computer system. The user
can perform a task by using a set of instructions through the computer hardware. So, the
combination of computer hardware and software makes up a full functioning computer
system that performs specific task. Motherboard, microprocessor, RAM, ROM, hard
disk, pen drive, keyboard, scanner, monitor, etc. are the examples of computer hardware.
a. Motherboard
Motherboard is called PCB (Printed Circuit Board) or system board or main circuit
board. All parts of computer system like microprocessor, slots, ports etc. are mounted
on motherboard. So, it is also called backbone of computer system. It also connects
important chips like ROM chip, Network chip, sound card, etc.
Motherboard
Function of motherboard
a. There are different slot which joins modem, TV card, etc. in motherboard.
b. Motherboard helps in data communication among different hardware.
c. BIOS (Basic Input Output System) programs are stored in ROM and ROM is
Microprocessor gets data and instructions from various hardware and processes it with
the help of software to produce information as an output to the user. It can do arithmetic
calculation and logical comparison between two numbers. Nowadays, a trillion of
instructions can be processed within a second.
Microprocessor
Working of Microprocessor
i. Fetch
The user can give data and instructions which is stored in RAM. Microprocessor receives
data and instruction according to necessity and requirement which is known as fetch.
So, fetch means get instruction from memory.
ii. Decode
The main function of microprocessor is to change fetched instruction into decoded
instruction. The given instruction is separated for arithmetic or logical calculation. So
decode means to decide what the instruction means.
iii. Execute
Microprocessor can perform the main task in this unit. For example, ALU is used for
mathematical calculation. So, execute means to carry out the instruction into action.
The complete cycle of four units as fetch, decode, execute and write back of
microprocessor for processing the instruction is called the instruction cycle.
c. Memory
The physical part of a computer that store data, information and software temporarily
or permanently is called memory or storage. Storage device or memory device is used
to store data and information. The three types of memory are as follows
i. Primary memory,
ii. Secondary memory and
iii. Cache memory.
Register
Magnetic Tapes
Memory Hierarchy
i. Primary memory
The main memory is called primary memory. Primary memory stores data temporarily
or permanently. It stores information during the processing of raw data. The two types
of primary memory are:
SRAM: SRAM stands for Static Random Access Memory. It does not need periodic
refreshing to preserve the information. It is faster and expensive than DRAM.
RAM
ROM (Read Only Memory)
ROM is a non-volatile or permanent memory. Non-volatile means never loses data in
ROM. It stores data permanently even when the computer is switched off or power
failure. It is read-only memory because the programs in ROM are stored at the time of
PROM
PROM stands for Programmable Read Only Memory. Once a program has been written
onto the PROM, it remains there forever and can't be updated and deleted.
EPROM
EPROM stands for Erasable Programmable Read Only Memory. It can be erased by
ultraviolet light and reprogramming.
EEPROM
EPROM stands for Electrical Erasable Programmable Read Only Memory. It is called
flash ROM. It can be erased by exposing it to an electrical charge and reprogramming.
It is also called hybrid memory with a combined feature of RAM and ROM.
ROM
Firmware
Firmware is software that's embedded in a piece of hardware. So, the firmware is
software for hardware.
CPU Register
CPU Register is a small storage memory, located inside the microprocessor and has a
high speed data transfer rate. It stores data and instructions used by the microprocessor.
Cache Memory
Cache memory is also like CPU Register, located inside the microprocessor but has
high storage capacity than CPU Register and high-speed data access rate. It also stores
the data and instruction used by the microprocessor. So, it stores very active data and
instructions temporarily during processing. If required data and instruction are not found
in cache memory then the searching is done in primary memory.
Computer Science : Grade 9 33
ii. Secondary Memory
Secondary memory is also called auxiliary memory or backup memory. These memories
are used to store data and instructions permanently for future use. CD/DVD, pen drive,
hard disk, etc. store data and instruction for future. The various types of secondary
memory are Magnetic Tape, Hard disk, SSD (Solid State Drive), Optical Storage Disc,
Pen drive, etc.
a. Magnetic Storage
Computer systems need to store data in digital format. One of the most widely used
types of digital data storage is magnetic storage. This refers to any type of data storage
using a magnetized medium. Several types of magnetized media are used in computer
systems, including magnetic tape, floppy disks, Super disks, hard disks, etc.
Magnetic Tape
Magnetic Tape is a usable secondary storage device to store and retain a large volume
of data. It is made up of a plastic strip of which one surface is coated with magnetic ink.
Analog and digital data are stored in magnetic tape. Normally, minicomputer, mainframe
computer, large scale business organization server, etc. uses magnetic tape for backup
data and information. Magnetic tape driver are used to store and retrieve the data and
information from magnetic tape. The main important function of magnetic tape is to
store data safely for a long period of time.
Pen drive
b. Optical Storage Disc
The disc that uses laser light technology to store and retrieve data is called optical storage
disc. The most commonly used optical storage discs are CD, DVD, Blu-ray disk, etc.
CD (Compact Disc)
In 1980, Philips Company of Netherland developed first CD or optical disk which
was 12cm in diameter and had 72 minutes audio/video storage capacity. The laser ray
technology is used to retrieve and store the data. The information on the optical disk is
stored in the form of pits. The pits are tiny reflective bump.
CD has the diameter of 12 cm. It's weight is 18gm and width 1mm (millimetre). The
data can be written on a CD only once. CD is made up of poly carbon and both surfaces
are coated with aluminium. Nowadays, CDs are commonly used in microcomputer. It
can be used to transfer data from one computer to another. The storage capacity of a
CD is 700MB.
CD (Compact Disk)
DVD (Digital Versatile Disc)
DVD stands for Digital Versatile Disc or Digital Video Disc. Its storage capacity is
higher than CD. It stores multiple layers of data. The various DVD storage capacities are
Single Side Layer- 4.7 GB
Single Side Double Layer-8.5 GB
Double Layer Single Side- 9.4 GB
Double Layer Double Side-17.08 GB
Philips, Sony, Toshiba/ Panasonic companies developed first DVD in 1995. DVD Drive
is used to read/write the data on DVD.
DVD
Blue-ray Disc
It is an optical data storage device. Its storage capacity is up to 200GB. It is mainly used
to store high-quality audio and movie data. It is scratch resistant discs.
Bit
Bit stands for Binary digit. The value of the binary digit is 0 or 1.
Byte
Byte is the combination of 8 bits.
d. Input Device
The devices through which raw data and instructions are entered into the computer
system are called input devices. The user gives raw data into the computer for processing
through the input devices. Keyboard, mouse, joystick, microphone, etc. are examples
of an input device.
i. Keyboard
Keyboard is a common input device. The data is entered into the computer by typing
through the keyboard. The most common layout of the keyboard is "QWERTY"
keyboard. The different keys present in the keyboard are:
Keyboard
ii. Mouse
The mouse is a pointing input device. It is used to point object, give command, draw
paint, etc. into the computer. The common three buttons of a mouse are:
i. Left Button
ii. Right Button
iii. Scroll Button Mouse
The user uses buttons for clicking, double clicking, right-clicking, dragging, scrolling,
etc. to give command into the computer.
The mouse was developed by Douglas Engelbart in 1964 that was of wood. Apple
Macintosh was the first computer to use mouse. Mechanical mouse, optical mouse and
wireless mouse are different types of mouse.
iii. Joystick
Joystick is an input device which is used to play video games. There
are different types of joystick available for various video games.
It has more buttons that help in playing and controlling objects in
Joystick
games.
vi. Scanner
Scanner is an input device which scans drawing or document
and enters into computer in digital format. The photocopy
machine gives the facility of the scanner. Scanner converts Scanner
hardcopy into soft copy.
ix. Microphone
Microphone is a sound input device. It helps to input sound or music
into the computer in a digital format. It is used in audio chatting and
video conferencing through Skype, Viber, Facebook, messenger etc.
Microphone
x. Digital Camera
Digital Camera is an input device that takes photographs or
video and enters them into the computer system in digital
format. It stores the file in SD card. The data from the SD
card then get transferred into the computer through a cable.
Mobile phone camera is also an example of digital camera.
Digital Camera
xi. Graphic Digitizer
Graphic Digitizer is an input device. It is a device
used to convert hand sketch image or signature
into digital format to the computer. It is also called
digital tablet. Stylus (electronic pen) helps to draw
an image onto the flat surface and send to the
Graphic Digitizer
Computer Science : Grade 9 43
computer for digital store. Graphic Digitizer is mainly used by designer and engineer.
Touch Screen
e. Output Device
The device which displays meaningful information from the computer is called an
output device. So, an output is the result produced by processing unit. The common
output devices are monitor and printer. Some other output devices are: plotter, speaker,
headphone, etc.
Monitor
Monitor is the most common output device. It is also called VDU (Visual Display
Unit) in computer system. The output displayed on monitor's screen in the form of text,
videos and graphics is called soft copy output. On the basis of colour the monitors are
of two types:
i. Screen Resolution
It represents the number of horizontal and vertical pixels. The clear screen is due to the
high resolution of the monitor. The common resolution ranges are 640 ˟ 480, 1024˟768,
1600˟1200 etc.
On the basis of technology, monitors are classified into three types as:
i. CRT Monitor
CRT stands for Cathode Ray Tube. It operates in the following ways:
The electron gun emits a beam of electrons cathode rays.
The electron beam passes through focusing and deflection systems that direct it
towards specified positions on the phosphor-coated screen.
When the beam hits the screen, the phosphor emits a small spot of light at each
position contacted by the electron beam.
It redraws the picture by directing the electron beam back over the same screen
points quickly.
Computer Science : Grade 9 45
CRT Monitor
There are two ways Random scan and Raster scan by which we can display an object
on to the screen.
ii. LCD Monitor
LCD stands for Liquid Crystal Display. It is very light, thin and consumes less power
than CRT monitor. The two-layer in this monitor which consists of liquid crystal form
an image. It is used in laptop, notebook, digital watch, desktop computer, etc. It is
more expensive than CRT monitor and produces a high quality image on the screen.
The fluorescent lamps are used for backlighting in LCD monitor for displaying image
on the screen.
LCD Monitor
iii. LED Monitor
LED stands for Light Emitting Diode. It is very lighter and thinner than LCD and CRT
monitors. It consumes less power than CRT and LCD monitors. Its working power is
higher than others. So its lifetime is more and can be used for long-time-work. The
quality of image on the screen is higher than that of other monitors. The diodes are used
for backlighting in LED monitor for displaying the image on the screen. LCD and LED
monitors are called flat panel displays.
Impact printer
Non-impact printer
Impact Printer
An impact printer is a type of printer that operates by striking a metal or plastic head
against an ink ribbon. Its structure is like a typewriter. It uses small pin-like objects or
hammers that strike on the inked ribbon and characters are formed on the paper. These
printers are slow and noisy. These printers use black or blue or red colour. The printing
quality of impact printer is lower than non-impact printer.
Drum printer: In this type, there is a cylindrical drum which continuously rotates over
the paper surface and causes characters rise and hits on the ribbon.
Chain Printer: In the chain printer, high-speed print chain is used. This chain contains
different types of characters.
48 Computer Science : Grade 9
Drum Printer
Band Printer: In this line printer, steel print band is used to print one line printout on
paper at a time.
Non-Impact Printer
The non-impact printer does not use the printing head to strike against ribbon and paper.
Instead, small drops of ink are sprayed onto the paper. So non- impact printers are faster
and are of high quality than impact printer. It does not produce sound while printing.
Inkjet printer, laser printer, 3D printer are the popular types of non- impact printer.
i. Ink-jet Printer
Inkjet printer prints text and graphics on paper by spraying small drops of ink into paper.
The speed of inkjet printer is generally 1 to 4 pages per minute. It uses an A4 size paper.
The liquid colour-filled cartridge is used instead of ink ribbon. Colour inkjet printer
uses black colour. Four colour-CMYK (Cyan, Magenta, Yellow, Black) cartridges are
used for colour printout.
Inkjet Printer
ii. Laser Printer
A laser printer is a type of printer which makes use of a laser beam to produce an
Laser Printer
iii. 3D – Three Dimensional Printer
Impact printer & non-impact printer prints text on paper but 3D printer prints an object.
For example, any playing toys or any machinery parts are printed through the 3D printer.
3D printing builds parts out of plastic, metal and other materials directly from CAD
(Computer-Aided Design) drawings that have been cross-sectioned into thousands of
layers. This technology helps to build a 3D object by modelling. This technology is
called additive manufacturing.
3D Printer
iii. Graphic Plotter
The graphic plotter is a hard copy output device which is used for good quality print
or drawing like charts, map, engineering design, etc. Figures or maps are printed on
Pen plotter: Pen plotter contains one or more pen. It prints colour drawing with shade.
Electrostatic plotter: Electrostatic plotter does not contain any type of pen. It prints
like laser printer.
Dot-matrix plotter: Dot matrix plotter prints drawing like impact printer. Print head
strikes on ink ribbon and prints images on paper.
Graphic Plotter
iv. Speaker
Speaker is a common audio output device. It is used to receive sound or music from
computer system. It is used to covert digital data into audio analog data which user can
understand. The quality of sound output depends on the speaker's quality. For example,
loud speakers, sub woofers, in- wall/ceiling speaker, outdoor speaker, etc. are the
different types of speakers.
Speaker
Technical Terms
Hardware : the physical parts of a computer which can be touched, seen
and felt.
Fetch : get an instruction from memory.
Decode : decides what the instruction means.
Write back : microprocessor processes the instructions and produces result.
Primary memory : stores data temporarily or permanently.
Cache memory : the high-speed execution memory.
Secondary memory : stores data and instruction permanently for future use.
Magnetic Tape : store and retains a large volumes of data.
52 Computer Science : Grade 9
Input device : the devices which are used to enter raw data and instructions
Output device : the device which displays meaningful information
Screen Resolution : represents the number of horizontal and vertical pixels.
Refresh Rate : rate where each pixel on the screen is re-drawn.
Speaker : a devoce to receive sound or music from computer system.
Exercises
1. Answer the following questions.
a) Define computer hardware with its importance in computer system.
b) What is a microprocessor? How does it work? Explain.
c) What is computer memory? Write its major classification.
d) Why is secondary memory used for future storage? Explain with its types.
e) What is a motherboard? What does it contain?
f) How does a computer mouse work? Who developed it?
2. Differentiate.
a) RAM and ROM
b) Primary and Secondary memory
c) Input and Output devices
d) Magnetic storage disk and Optical storage
e) Hard disk drive and Solid state drive
f) Impact and nonimpact printers
Project Work
1. Prepare a presentation about different hardwares found in computer lab and
demonstrate in your class as a group discussion.
2. Draw a chart paper about different types of computer hardware with name and
paste in your classroom.
3. Consult your computer teacher to follow the steps 'how to store information in
cloud storage' and demonstrate in a sheet of chart paper.
4. Visit IT solution offices such as computer maintenance centre and sales, and
collect information on the latest devices.
The combination of hardware and software to perform a task is called computer system.
The set of instructions or programs written by using a programming language to solve
a problem is called computer software. So, software controls and operates computer
hardware to perform a task. The set of instruction or command is called program. The set
of program to perform a specific task is called software. Generally, computer software
is classified into two types.
a. System software
b. Application software
a. System Software
The software that manages controls and supports computer system is called system
software. So, system software creates link between computer and user. It is a platform
for running application software. It manages files and folders. It can be sub-divided
into the operating system, utility software, device driver software, language processing
software, etc.
i. Operating System
An operating system is the system
software that manages and controls
the overall operation of computer. It
coordinates, controls and manages
computer hardware. The operating
system is installed in C: drive of hard Operating system
disk. It is the first software that is loaded
into computer memory (RAM). The popular operating system are Windows XP, Windows
7, Windows 8, Windows 10, Linux based fedora, UNIX, MS-DOS etc. Android KitKat,
Android Marshmallow, Android Oreo are the popular operating system of Android
smartphone and IOS is the operating system of Apple iPhone.
a. Memory Management:
Operating system performs the task of allocation and de-allocation of RAM-memory
space needed to run programs and other resources.
b. Processor Management
Operating system must allocate resources to processes and enable processes to share
and exchange information.
c. Device management
Operating system co-ordinates with all devices like keyboard, printer, monitor, mouse
etc. So, the operating system helps to manage input, process and output devices.
d. File Management
Operating system manages all files in computer. It keeps records of filename, type,
size, location, etc.
e. Security
Operating system provides a security mechanism while using a computer. For example,
password is used in a system to prevent unauthorized access.
The operating system can be classified into two types based on the mode of the user as:
DOS Screen
GUI (Graphical User Interface)
In this type of operating system, the user gives command to perform the tasks by clicking
on icons, buttons and menus using a mouse. It uses keyboard as well as mouse and it
is user-friendly in comparison to CUI operating system. MS Windows 7/8/10, Linux,
etc. are the examples of GUI.
Nowadays, Microsoft Corporation develops GUI based operating system. Windows
operating system users have increased.
Windows is a GUI based operating system that controls all activities of computer system.
In this operating system, the user uses different application program and document
display on window. So it is named as Windows.
Mouse is used to open file, shut down computer and perform different commands in
windows operating system. The user does not need to remember long commands to
perform task. Nowadays, Windows10 is the latest operating system.
Computer Science : Grade 9 59
ii. Language Processor
A computer is an electronic machine. So it understands machine level language (binary
language: 0 or 1). A computer program is a set of instructions to perform tasks.
System software that converts different programming language into machine level
language is called language processor. So language processor converts high-level
language or assembly language into machine level language and vice versa.
a. Assemblers
An assembler is a type of language processor which converts program code written in
assembly language into machine language. Machine level language uses binary digit,
0 or 1 to write a program which is difficult. So a programmer writes programs using
assembly language. Mnemonic Code is used for writing program in assembly language.
Source Code
Assembler Object Code
(Assembly Language) (Machine Language)
Assembler
b. Compilers
The high-level programming language is developed for the improvement of assembly
language. A compiler is a type of language processor which converts the program written
in high-level language into machine level language at once. The equivalent machine
code obtained after translation is called object code. So the process of converting source
code into object code is known as compilation. The compiler specifies the errors at the
end of compilation with line numbers when there are any errors in the source code.
The errors must be removed before the compiler can successfully recompile the source
code again. C, C#, C++, Java, PHP, etc. are compiler-based programming languages.
Compiler
c. Interpreter
Interpreter is a type of language processor which converts the program written in high-
level language into machine level language line by line. If there is any error in the
middle of the program then program is interrupted in between. So, after removing the
error, the program needs to run again from the beginning. LOGO, QBASIC, BASICA,
Desktop
Once the computer is started, user name and password is typed and a screen opens
up that is called desktop. The background area of the Windows screen is desktop.
Desktop contains icons, taskbar, start button, etc. which is opened by clicking with
62 Computer Science : Grade 9
mouse. Desktop element differs according to versions of Windows like Windows XP
and Windows10. The user can add/remove icons on desktop.
Recycle Bin is a system folder which contains deleted file and folders. It
is very useful for recovering the files and folders which are accidentally
deleted. Select the file and press delete button to transfer to recycle bin.
But pressing shift + delete button on selection will permanently delete
selected file from hard disk. The file and folder can be restored from Recycle Bin
recycle bin to their original location if needed for use in future.
Documents
Document is a system folder of desktop. It is created while installing
Windows operating system. The user stores the document in document
folder.
Documents
The user gives command by clicking mouse for different purposes. The actions of mouse
and their uses are as follows:
Word Meaning
Point To put mouse pointer on icon or item.
Click Once click left button of mouse and release it.
Right Click Once click right button of mouse and release it.
Double Click Click left mouse button of in quick succession and release it.
Point and click the item or icon by left button and drag into the new
Drag and Drop
location or place and drop it.
Dialog Box
It is also called a communication box. It
appears to perform a task or command
like file save, document print, etc. to
user in Windows operating system. The
dialog box contains option like ok button
or cancel button. Here, press Ok button
if it is satisfied to send the command to
the computer and press cancel button
if unsatisfied. So the user can choose
different option by means of GUI control Font Dialog Box
64 Computer Science : Grade 9
and perform the tasks.
b. CheckBox
A small square box which
allows a user to select the
available option or multiple
selections is called checkbox. Check Box
c. List Box
The series of options displays on the box is called list
box. The option of list box can be viewed by clicking
on item.
Filename Extension
Media file (Video File) - .mp4, .mpeg, .avi, .flv, .wmv
Audio file (Audio File) - .mp3, .wav, .aac
Picture file (Image File) - .jpg, .gif, .png, .ico
Office Document - .doc, .docx
E-Book File - .pdf
Spread sheet file(Excel File) - .xls, .xlsx
Folder
Folder is a container which stores file, program and subfolder. It is also known
as directory in DOS. Subfolder is located inside the folder and store data and
information.
b. File Explorer
Click on Search Windows icon and type file
explorer near to start button on desktop.
Then click on the File Explorer menu.
There appears File Explorer window and as a
requirement of the user, click on file located on drive
or folder.
File Explorer
66 Computer Science : Grade 9
Creating a new folder
Double click on This PC.
Double click on drive or folder where you wish to create a new folder.
Right-click on an empty area of the of window.
There appears temporary Floating Menu.
Select "New" and click "Folder" and type folder name and press "Enter" key on
the keyboard.
Note: While deleting the folder, all files and folders inside that folder also get deleted.
Ms office package, Adobe Photoshop, Windows 8/10, etc. are called proprietary
softwares which do not provide source code to user after payment.
In open-source software, the user modifies source code according to user requirement.
Open-source software was started by Richard Stallman in 1983. Richard Stallman
announced the GNU Project in 1983. Free Software Foundations was established in 1985.
Some proprietary software and their alternative open source software are listed below:
Freeware
Freeware is a software available free of charge. It is copyrighted by its developer. The
developer retains the rights to control its distribution, modify it and sell it in the future.
Freeware is typically distributed without its source code, thus preventing modification
by its users. So, it may be freely downloaded, installed, used and shared.
Source code can be written in any programming languages. Some of the most popular
programming languages are C, C++, Java, Perl, PHP, etc.
Freeware is usually distributed with a license that permits its redistribution to some
extent. For example, allowing users to give copies to friends. However, there may be
restrictions, such as limitations on its commercial use. Some licenses permit the software
to be freely copied but not sold.
iPhone of Apple Company provides app store service of downloading various apps.
Microsoft facilitates its users with Microsoft Store to download desktop apps.
Nowadays, web browser-related apps are used in all smartphones and computers. For
example, Google Company developed Google Chrome as a web browser.
Google play
Technical Terms
Computer Software : Program which controls and operates computer hardware to
perform a task.
Computer Science : Grade 9 71
Operating system : Co-ordinates, controls and manages computer hardware and
resources.
Desktop : The background area of the Windows screen.
Icon : The small picture buttons that represent files, folders,
programs, etc.
This PC : A gateway to user to see contents of storage device.
Recycle Bin : Contains deleted files and folders.
Language processor : Converts high-level language and assembly language into
machine level language and vice versa.
Compiler : Converts the program written in HLL into MLL whole
programme at once.
Utility software : Maintains computer software and hardware.
Application software : Designed to fulfil the requirement of the user.
OSS : Freely available software and source code.
Exercises
1. Answer the following questions.
a) Define computer software with its importance in computer system.
b) Explain operating system with examples.
c) What is computer memory? Write its major classification.
d) Mention major functions of operating system.
e) How does utility software maintain computer system? Give the name of
some utility software.
f) Briefly explain about application software with its types.
g) Distinguish between system software and application software.
h) Give the special features of packaged software.
i) What is the language processor? Write its types.
j) What is open-source software? Give examples.
Project Work
1. Collect names of softwares used in hospital, hotel, educational sector and other
different sectors in your locality about and discuss in groups main objectives of
the softwares.
2. Draw in chart paper the different types of computer hardware with name and paste
in your classroom.
3. Name one useful open source software that you are familiar with. List its features.
Prepare a presentation and demonstrate in your classroom.
4. Take a short interview with your teachers, friends, parents and relatives and
prepare a field report about what types of computers, laptops or other devices
they are using, what types of operating system the device has. Also, make a list
of apps that they have used in their smartphones.
5. Make a presentation of system, application and utility software used in your
computer lab.
Introduction
The term "Graphics" is derived from the Greek
word 'graphikos', which means 'something written'.
Graphics can be defined as visual data in the form of
images or designs created to inform or communicate.
Such visual images that are generated by a computer
are called computer graphics.
Computer Graphics is an important area in computer
applications. The term Computer Graphics includes everything that is presented
through images. Graphics provide visual feedback to the user. Hence, it is considered
as an important component of communication.
Computer Graphics includes everything that is presented through images developed
or designed using different graphical software. Graphic design is a means of visual
communication. As you have heard an English proverb "A picture is worth a thousand
words", with a good graphical design, you can express your message more effectively
and beautifully. Our brain processes visual information so much more effectively and
quickly than textual information. Therefore, Graphics is a very important communication
component in present days.
The term “Computer Graphics” was first used by William Fetter, Graphic Designer of
Boeing Company in 1960.
Uses of Computer Graphics
a) Publication of books, magazines, newspapers etc.
b) Cartoon movies and computer games
c) Educational materials
d) Computer simulation, VR-Virtual Reality, scientific modelling, engineering design
etc.
Adobe Photoshop
GIMP (GNU Image Manipulation Program)
Google Drawing
Adobe Illustrator
CorelDraw
Paint.net
a) Raster Format
Raster format (also called Bitmap images) are composed of tiny squares called pixels
(px), and each pixel is assigned a specific colour. If a JPG or GIF image is magnified
greatly in a program like Adobe Photoshop, individual pixels can be viewed and changed.
Pixel is the smallest element of a raster image.
A pixel (short for Picture Element) is the smallest addressable element of a picture
represented on a screen. The number of pixels determines the image quality. Common
file extensions of raster formats are JPG, GIF, BMP, TIF, and PNG.
b) Vector Format
Unlike raster format, vector images are not composed of pixels. Digital information is
stored using some mathematical formula in a vector image. The main feature of vector
graphics is that its quality remains the same when you enlarge it to any size. Common
file extensions of vector formats are AI, PDF, SVG, EPS
JPG Graphics
JPG is the most used image file format.
Digital cameras usually produce images in JPG format
Suitable for images with a lot of different colours, like photographs
GIF Graphics
The second most common image format used on the World Wide Web after JPEG.
Suitable for images that require a few distinct colours, such as line drawings,
logos, b/w images or images with few colours.
PNG Graphics
Newest file format.
Better compression and transparency features than GIF.
1 inch – 72 pixels
Total number of pixels per square inch = 5,184 pixels (72 pixels x 72 pixels)
In the same way, if the resolution is 300 pixels/inch then the number of pixels per square
inch will be 90,000 pixels.
DPI – It only refers to a printer. It indicates the number of physical dots of ink in a
printed document. For example, 1200 dpi printer uses 1200 dots of ink in every inch
to make up the colours.
Adobe Photoshop
Adobe Photoshop is a professional image editing software that can be used to create a
new image or edit an existing one. Most of the graphic designers, web designers, graphic
artists, photographers and creative professionals use this popular tool.
Adobe Photoshop is a very popular software because of its different image editing and
retouching effects. Adobe Photoshop allows users to manipulate, crop, resize, correct
colour, apply effects, add text and many other editing tasks.
Photoshop Workspace
Tools Panel
This palette contains some groups of tools that are used to edit and manipulate images.
Here, text tool and some selection tools of tools panel are discussed:
Note: The character in the bracket in Tools Panel is a shortcut key to activate the required
tool. For example, press V to activate Move tool.
Adding Text
Follow the steps to add text:
Step 1: Create a new file or open an existing image file.
Step 2: Click on Type tool from Tools panel or simply press "T".
Step 5:Click and drag anywhere in the workspace (new image or existing image)
window to create a text box.
Moving Text:
Select the text layer.
Select the Move tool or press V.
Click and drag the text to the required location.
Edit the Text
Double-click on the layer icon
of the required text.
or,
Select the type tool and click
on the text. The text will be
highlighted.
Now, you can modify the text,
text size and colour
Selection Tools
Selection tool is one of the mostly used tools in Photoshop while manipulating or
designing images. Selection tools are used to isolate different part of an image so that
we can work only on that particular area without affecting the rest of the image.
Marquee Tool
Marquee tool is a basic selection tool available in Photoshop. It allows the user to make
a rectangular or elliptical selection of a certain part of an image. It also provides 1-pixel
rows and columns selection.
Step 3: Click and drag over the area of the image you want to select.
Note: Hold down shift button while dragging to constrain the marquee to square or
circle. You can cut, copy or apply some other effects on the selected portion of the image.
Lasso Tool
Lasso Tool allows the user to draw
freehand selections around objects.
Besides the standard Lasso tool,
Photoshop provides two other types
of Lasso tool: Polygonal Lasso Tool
and Magnetic Lasso Tool.
Enter the Tolerance value (up to 255). Higher tolerance value, wider range of
color selection.
Click the color in the image that you want to select.
Method #1:
Using the Options bar of selection tool
To add: Click Add to selection button and click elsewhere in the image
To subtract: Click Subtract from selection button and click inside the selection.
Method #2:
Using Keyboard Keys
Note: These adding and subtracting features are applicable in Marquee and Lasso tools
also.
Cropping Images
Cropping images is one of the most basic, but important photo editing
features available in Photoshop. Cropping feature allows you to remove
unwanted outer parts of image.
Crop Tool
Summary
Computer Graphics includes everything that is presented through images
developed or designed using different graphical software.
Some popular image editing software includes Adobe Photoshop, GIMP, Adobe
Illustrator, CorelDraw, Paint.net etc.
There are two main types of Graphical Format: Raster and Vector
Raster images are composed of tiny dots called pixels. JPG, GIF, BMP, TIF and
PNG are common raster formats.
Vector graphics are composed of paths or lines. AI, PDF, SVG and EPS are
common vector formats.
Image size refers to the length and width of a digital image, also called pixel
dimensions.
94 Computer Science : Grade 9
Resolution refers to the number of pixels in an image.
Adobe Photoshop is a professional image editing software that can be used to
create a new image or edit an existing one.
Different selection tools available in Photoshop are Marquee Tool, Lasso Tool
and Magic Wand Tool.
Cropping feature allows the user to remove unwanted outer parts of image.
Technical Terms
(a) Graphics : Visual data created to inform or communicate
(b) Computer Graphics : Images developed using graphical software
(c) Graphics Software : Software used to draw or design simple to complex
graphics
(d) Raster Image : Images composed of pixels
(e) Vector Image : Images composed of paths or lines
(f) Pixel : The smallest addressable element of a raster image
(g) Resolution : Dimension of an image measured in dpi or ppi
(h) Text Tool : Allows to add text on an image
(i) Selection Tool : Allows to select a required part of an image
(j) Cropping : Allows to remove unwanted outer part of an image
Exercises
1. Answer the following questions.
a) Define Computer Graphics.
b) What are the application areas of Computer Graphics?
c) Differentiate between Raster Image and Vector Image.
d) Mention the list of different image file formats.
e) Write some features of JPG and GIF images.
f) What is a pixel?
Activities
1. Prepare a presentation file on “Importance of Computer Graphics and its uses”
and present it to your class as a group work.
2. Collect the names, logo, application areas, file extensions and other related
information of different Graphics Software and draw in a sheet of chart paper.
Practical Work
1. Open any image file in Photoshop and change its width to 600 pixels and height
800 pixels.
2. Create a collage of 7 wonders of the world. Also write their names.
3. Search few jpg files in your computer. Open any one of them and save the same
file in PNG format.
4. Open any graphic file and demonstrate the uses of different selection tools.
5. Open any one JPG file. Remove some unwanted portion using crop tool and save
it in GIF format.
6. Run MS-Paint. Create a graphic file and save in BMP format. Open the same file
in Photoshop and save it in JPG format.
3.1 Introduction
Many of you might have heard of the term ‘Internet’. Nowadays, it is popularly used
to search for information on any subject, to communicate with people, for shopping,
for knowing the latest news, booking tickets, playing game, sending greeting cards and
for a number of other purposes. Let us learn what exactly the internet technology is.
Today, the internet connects thousands of networks and hundreds of millions of users
around the world. It is a huge, cooperative community with no central ownership. This
lack of ownership is an important feature of the Internet because it means that no single
person or group controls the network. The Internet is open to anyone who can access
it. If you can use a computer and if the computer is connected to the internet, you are
free not only to use the resources posted by others, but to create resources of your own.
The seeds of the internet were planted in 1969 when the Advanced Research Projects
Agency (ARPA) of the U.S. Department of Defence began connecting computer
at different universities and defence contractors. The resulting network was called
ARPANET.
Web Server
The Web is a collection of Internet host systems that make these services available on
the Internet using the HTTP (Hypertext Transfer Protocol). Web-based information is
usually delivered in the form of hypertext and hypermedia using HTML.
Many people believe that the Web and the Internet are the same things, but this is not
correct. In fact, they are two different things. The web is a service (a system for accessing
documents) that is supported by the Internet (a gigantic network).
3.1.3 DNS
DNS stands for Domain Name System (or service or server) and is an internet service
used for converting domain name into IP address on the internet or on local networks
using the TCP/IP. DNS automatically converts the website name typed in web browser
address bar into the IP address of web server hosting that site. For example, the domain
name https://www.moecdc.gov.np might translate to 202.45.144.44
3.1.10 Download/Upload
Downloading means your computer is
receiving data from the internet. Downloading
is the transmission of a file from one computer
system to another. From the Internet user's
point-of-view, to download a file is to request
it from another computer (or from a web page
on another computer) and to receive it.
Where Uploading means data is being sent from your computer to the Internet. From an
internet user's point-of-view, uploading is sending a file to a computer that is set up to
receive it. Examples of uploading include sending an email, posting photos on a social
media site and using your webcam.
3.1.11 Netiquette
The word netiquette is a combination of 'net' (from Internet) and 'etiquette'. It means
respecting other users' views and displaying common courtesy while doing online
activities.
Companies offering these computing services are called cloud providers and typically
charge for cloud computing services based on usage, similar to how we paid the bill
for water, electricity, telephone at home. Some of the cloud providers are Amazon
AWS, Microsoft Azure, Google Cloud, IBM Cloud, VMware Cloud, Oracle Cloud and
Alibaba Cloud.
You are probably using cloud computing right now, even if you don’t realise it. If you
use an online service to send an email, edit documents, watch movies or TV, listen to
music, play games or store pictures and other files. It is likely that cloud computing is
making it all possible behind the scenes. Cloud computing can be broken up into three
main services: Software-as-a-Service (SaaS), Infrastructure-as-a-Service (IaaS) and
Platform-as-a-Service (PaaS).
Technical Terms
world wide web (www) : An internet service developed to incorporate footnotes,
figures, and cross-references into online hypertext
documents.
Web Server : An internet host computer that may store thousands of
web sites.
Internet Protocol Address : A unique four-part numeric address (between 0 and 255)
assigned to each computer on the internet, containing
routing information to identify its location.
Index page : The default page, or main web page of a website.
Hypertext Markup Language (HTML): A page-description language used on the
world wide web that defines the hypertext links between
documents.
Exercises
1. Answer the following questions.
a. Define the term “Internet Technology”.
b. What is the Web Browser? Name any four web browsers.
Activities
1. Complete the following exercises as directed by your teacher.
a) Prepare a list of search engines using the Internet.
b) Practice using your browser. Launch your browser and practice navigating
the Web. Try using URLs based on the names of people of companies you
want outlearn more about. As you visit different sites, look for hyperlinked
Computer Science : Grade 9 111
text and graphics; click them, and see where they lead.
c) Search, search, search. Pick a topic and search the Web for information
about it. Pick a keyword to use in your search, then visit three search engines
and use each of them to conduct a search using your chosen keyword. Use
Bing, Altavista, and Google for your searches.
d) Prepare an article on “Internet Safety”. Using the Internet, find some
information about the topic and include in your article and also mention
the name of the website you visited.
2. Make a PowerPoint presentation on the topic.
“How are the Internet and its services helping us to develop a better society?”
Project Idea
Choose one service that Internet has been providing us or you can imagine
(develop) a new idea which is possible through the Internet. Limit yourself with
only one service/idea and present it in-depth with all the required specificity. Your
presentation may include multimedia files, pictures, cartoons, graphs, bar charts
etc. Your presentation may include information in the following order:
a) Introduction : (Define/introduce that idea/history of idea/summary of things
you are going to present in this presentation)
b) Main Body : (Its use/beneficial aspects or target group/how it works,
argumentation about do’s and don’ts, relate human development in socio-
economic prospects, benefits and limitations with examples)
c) Conclusion: (Conclude your argumentation with logical interpretation and
integrate it with human development.)
3.1 Introduction
In the previous lesson, you learnt that the language used to develop web pages is called
Hypertext Markup Language (HTML) where Hypertext is a text which contains links to
other texts. By clicking on a link in a hypertext document, a user can quickly jump to
different content. For example, software that includes dictionaries and encyclopaedias
has long used hypertext in their definitions so that readers can quickly find out more
about specific words or topics. Though hypertext is usually associated with Web pages.
A Markup Language is a computer language that uses tags to define elements within
a document. It is human-readable; markup files contain standard words, rather than
typical programming syntax. While there are several markup languages the two most
popular are HTML and XML (Extensible Markup Language). HTML was invented
by Tim Berners-Lee at CERN, the European Particle Physics Laboratory. The World
Wide Web Consortium (W3C) is the standard organization that controls the evolution of
HTML. The W3C provides a list of recommendations regarding the use of HTML and
other associated technologies and you should try to adhere to these recommendations
when you are writing your own web pages.
a. Container Tag: Most tags come in pairs and surround the material they affect.
They work like a light switch: the first tag turns the action on, and the second
turns it off. For example, the <B> tag is a container tag. It is also called paired tag.
In paired tags, the first tag (<B>) is often called the opening tag and the second
tag (</B>) is called the closing tag. The opening tag activates the effect and the
closing tag turns the effect off.
Computer Science : Grade 9 113
b. Empty Tag: An empty tag does not have a companion tag. Tags that are used
by them are called empty tags. It is also called Singular or stand-alone tag. For
instance, the <BR> tag creates a blank line and doesn't have an "off switch".
3.2.1 Attributes
Some elements may include an attribute, which is additional information that is included
inside the start tag. For example, you can specify the FONT (size, color or face) by
including the appropriate attribute with the HTML code.
<Font Size = "+1"> Attention! </Font>
<HTML>
<HEAD>
..head section
</HEAD>
<BODY>
..body section
</BODY>
</HTML>
<HEAD> …</HEAD> This tag identifies the beginning and end of the header section.
<TITLE> This tag is used to place the text in the title bar of the browser window.
<BODY> …</BODY> This tag recognizes the beginning and end of the body section.
There are some attributes of the <BODY> tag which are used to specify the background
colour, text color, font size, font weight and so on.
BACKGROUND Specifies the name of the image (.gif) file that will be used as
the background of the document.
TEXT Changes the body text color from its default value to the color
specified with this attribute.
Here are the steps to create and save the HTML document in notepad.
In MS-Windows, Click the Start Button
Computer Science : Grade 9 115
Type Notepad in the search text box and hit Enter. (Notepad window will appear)
Type the HTML code in the Notepad window as shown in the figure below.
Save the file from File Menu>Save.
Notepad will display Save as dialog box asking for a file name as shown in the
figure below.
In the File name text box, type “Firstpage.htm” or “Firstpage.html”. Type the
filename and .html or .htm extension enclosed in the double quotes else the file
might be saved with TXT extension.
Click on the save button.
To view your Web page double click on your page “Firstpage.htm” and you can see it
in your default browser (like Internet Explorer or Mozilla Firefox). To view the source
code of your page you can just click on View menu and click source. Now you can see
the HTML source code as shown in the figure below.
For line breaks and paragraph breaks <BR> and <P> tags are used. Apart from simple
formatting tags, text-formatting tags are also used. These tags are used for changing
the color, size, alignment, font etc. of the text.
Paragraph Tag <P>: A blank line always separates paragraphs in textual material. The
tag that provides this functionality is <P>. At this tag, the browser moves onto a new
line skipping one line between the previous line and the new line.
ALIGN=LEFT | CENTER | RIGHT attribute can be used to set the alignment of the
paragraph. Left alignment is set by default.
Input:
<P> Please forward any inquires to [email protected]</P>
<P ALIGN=RIGHT> DATE: </P>
Line Break Tag <BR>: When text needs to start from a new line and not continue on
the same line (without skipping a blank line), the <BR> tag should be used. This tag
simply jumps to the start of the next line.
Input:
Government of Nepal, <BR> Ministry of Education, Science & Technology,<BR>
Curriculum Development Centre,<BR> Tel.:(977-1) 6630588, 6634119.
Output:
Government of Nepal,
Ministry of Education, Science & Technology,
Curriculum Development Centre,
Tel.:(977-1) 6630588, 6634119
Example 1
<HTML>
<HEAD>
<TITLE> An example of comment </TITLE>
</HEAD>
<BODY>
<!—body tag includes all the tags and other text-->
The comment tag used to insert comment in the HTML source code
</BODY>
</HTML>
Formatting Tags
Formatting tags are used to change the appearance of the text in web page. Formatting
tags can be used set the font face, font color, font size, bold, italics styles of the text.
Heading Styles <H1>…<H6>: HTML supports six different levels of headings. The
highest-level header format is <H1> and the lowest level is <H6>. All the styles appear in
BOLDFACE and the size of the heading depends on the level chosen, i.e. <H1> to <H6>
Input: Output:
<h1>This is a heading one.</h1> This is a heading one.
<h2>This is a heading two.</h2> This is a heading two.
Drawing Horizontal Lines <HR>: The tag <HR> draws line and horizontal ruler. This
tag draws a horizontal line across the whole page, wherever specified. The attributes
of the <HR> tag are:
Attributes Description
Aligns the line on the Browser screen, which is by default, aligned to
the center of the screen.
ALIGN ALIGN=LEFT will align the line to the left of the screen
ALIGN=RIGHT will align the line to the right of the screen
ALIGN=CENTER will align the line to the center of the screen
SIZE Change the size of the rule.
Sets the width of the rule. It can be set to a fixed number of pixels, or
WIDTH to a percentage of the available screen width.
Input:
Welcome to Nepal VisitNepal 2020!
<HR ALIGN= “LEFT” WIDTH= “20” SIZE= “4”>
Text Styles
To format your text, you can use the following tags. <B>…</B> tag to display text in
BOLDFACE style, <I>…<I> tag for ITALICS, <U>…</U> tag is uses to UNDERLINE.
The superscript <SUP>…</SUP> and subscript <SUB>…</SUB> tags are used for
placing the text above and below the specified text.
Input:
<b>this text is bold </b>
<i> this text is italicize </i>
Computer Science : Grade 9 119
<u>this text is underlined</u>
A<sup>2</sup>B<sup>2</sup>
H<sub>2</sub>O
Output:
this text is bold
this text is italicize
this text is underlined
A2B2
H2O
Text Effects
Centering (Text, Image etc.)
<CENTER>…..</CENTER> tags is used to center everything found between them
– text, lists, images, rules, tables or any other page element.
Input:
<CENTER> Welcome to Pokhara VisitNepal 2020! <CENTER>
Controlling Font Size and Color:
All text specified within the tags<FONT> and </FONT> will appear in the font, size
and color as specified as attributes of the tag <FONT>. The attributes are:
Input:
<FONT face= “Comic Sans MS” Size=6 Color=Red> Welcome to Nepal
VisitNepal 2020! </Font>
If you would like to specify a certain text or background color, you can do so by using
color codes.
120 Computer Science : Grade 9
RGB color codes are represented as hexadecimal values. The RGB color codes contain
three sets of numbers representing the amount of Red, Green and Blue contained in a
color. These codes must be used within your HTML to specify your selected colors.
Input:
<font color="#FF0000">RED </FONT>
<font color="#00CC00">Green </FONT>
<font color="#0000FF">Blue </FONT>
The MARQUEE Tag
The <MARQUEE> tag is useful for creating scrolling effect.
Input
<MARQUEE> COMPUTER SCIENCE !!!</MARQUEE>
<marquee behavior="scroll" direction="down" bgcolor="#CCFF00"
Example 2:
Some of these products include:
Pen drive
Hard Disks
Monitors
Ordered Lists (Numbering)
An ordered lists start with the tag <OL> and end with </OL>. Each list items start with
the tag <LI>. The attributes that can be specified with <LI> are:
Example 3:
Some of these products include:
<OL TYPE = “1” START=3>
<LI> Pen drive
<LI> Hard Disks
<LI> Monitors
</OL>
Output:
Some of these products include:
3. Pen drive
4. Hard Disks
5. Monitors
Definition Lists
Definition list values appear within tags <DL> and </DL>. Definition lists consist of
two parts:
Once an image is ready and stored in above-mentioned format, it can be inserted into
a web page using <IMG> tag, which takes the name of the image file (filename.gif,
filename.jpg or filename.jpeg) as the value of SRC attribute.
Attribute Value
SRC Location and name of the image file
Controls alignment of the text following the image
ALIGN = TOP indicates the text after the image to be written at the
tip, next to the image.
Example 5:
<IMG WIDTH = 447 HEIGHT = 57 BORDER =0 HSPACE = 0 SRC = “IMAGE1.
GIF” ALIGN=CENTER>
INPUT
<HTML>
<HEAD>
<TITTLE> USING LINKS TO CONNECT TO EXTERNAL SITES </TITLE>
<BODY BGCOLOR= “GREEN”>
<H2 ALIGN= “CENTER”>VISIT THE SITES TO KNOW ABOUT NEPAL</H2> <P>
<OL>
<LI> <A HREF= “http:// WWW.welcomenepal.com”> WWW.welcomenepal.com </A>
<LI> <A HREF= “http://WWW.explorenepal.com”> WWW.explorenepal.com </A>
<LI> <A HREF= “http:// WWW.lonelyplanet.com”> WWW.lonelyplanet.com </A>
<LI> <A HREF= “http:// mofa.gov.np”> mofa.gov.np </A>
</OL>
</BODY>
</HTML>
<A NAME= “WEB”> </A> <!--A NAME “WEB” is given to this location -- >
<OL> Visual Basic and the web
<OL>
<LI> Introduction to the Web
<LI> Scripting Objects
<LI> VB and the Web
<LI> Active Server Pages (ASP)
</OL>
Computer Science : Grade 9 131
</OL>
<OL>
<LI> Introduction to the Web
<LI> Scripting Objects
<LI> VB and the Web
<LI> Active Server Pages (ASP)
</OL>
</OL>
</OL>
</OL>
<A NAME= “LAST”> </A> <!--A NAME “LAST” is given to the this location -- >
<A HREF= “#TOP”> GO TOP</A> <!--Linked to the location named as “TOP”-- >
<BR>
<A HREF= “#DATABASE”> DATABASE SECTION </A> <!--Linked to the
location named as “DATABASE”-- >
<BR>
<A HREF= “#TOP”> WEB SECTION </A> <!—Linked to the location named
as “WEB”-- >
<BR>
</HTML>
132 Computer Science : Grade 9
Email Link
Apart from inter-page links and intra-page links, the <A> tag can also be used for
creating e-mail links. Email link creates a new message addressed to a specified recipient
using the web user’s installed mail client. For this purpose, the email address must be
specified after the mailto: statement in <A HREF> tag.
Example 12:
<HTML>
<HEAD>
<TITLE> USING EMAIL LINKS </TITLE>
</HEAD>
<BODY>
Send your email to <A HREF = mailto: [email protected]> Curriculum
Development Center, Sanothimi Bhaktapur </A>
</BODY>
</HTML>
3.2.6 Table
A table is a two-dimensional matrix, consisting of rows and columns. Tables are intended
for displaying data in rows and columns on a web page. All table-related tags are included
between the <TABLE> </TABLE> tag. Each row of a table is described between the
<TR> </TR> tag. Each column of a table is described between the <TD> </TD> tag.
Header rows
A table header row is defined using <TH> </TH> tag. The content of a table header
Bypassing a rows <TR> tag the VALIGN and ALIGN attributes, vertical or the horizontal
alignment can be made identical for every cell in a given row.
Bypassing the <TH> and/or <TD> tags, VALIGN or ALIGN attributes, vertical or
horizontal alignments in both header and data cells can be done. Any alignment specified
at the cell level overrides any default alignments and any alignments specified in a
<TR> tag.
Note:
Alignments specified in <TD> or <TH> apply only to the cell being defined.
Alignments specified in a <TR> tag apply to all cells in a row, unless overridden
by an alignment specification in a <TD> or <TH> tag.
Using the WIDTH and BORDER attribute
Example 13:
<HTML>
<HEAD>
<TITLE> Table Attributes </TITLE>
</HEAD>
<BODY BGCOLOR=LIGHTGREY>
<B> Specifying the BORDER and WIDTH of the Table! </B>
<BR> <BR> <BR> <BR>
Note:
If the WIDTH attribute is associated with the <TH> tag then the width of an
individual column can be adjusted.
Cell padding
Cell padding
<TR ALIGN=CENTER>
<TD> Bimala </TD>
<TD> 37 </TD>
</TR>
</TABLE>
</CENTER>
Computer Science : Grade 9 139
<HR>
<I>With cell spacing of 10 </I>
<CENTER>
<TABLE BORDER=1 CELLSPACING =10 WIDTH=25% ALIGN=CENTER>
<TR>
<TH> NAME </TH>
<TH> AGE </TH>
</TR>
<TR ALIGN = CENTER>
<TD> Sushila </TD>
<TD> 67 </TD>
</TR>
<TR ALIGN=CENTER>
<TD> Bimala </TD>
<TD> 37 </TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
The opening tag of the FORM tag includes attributes namely name, method and action.
Different types of form elements included in the <FORM> are text boxes, radio buttons,
checkboxes, drop-down boxes, multiline, scrollable text areas and password boxes.
Each of the form element will be placed inside a <FORM>… </FORM> tag.
NAME indicates the name of this field as passes to the script processing the form.
SIZE indicates the length of the text-entry field, in characters; the field is 20 characters
by default.
Example 18:
<form >
User Name : <Input type= "text" Name= "userName" >
<br><br>
Password : <Input type= "password" Name= "passwd" >
</form>
User Name :
Text box
Password :
Note: <input type = “password”> password text fields are identical to ordinary text
fields, except that all the character types are echoed back in the browser as asterisks or
bullets. Here   is used for one space
<Textarea Name= “theBody” Rows= “7” Cols = “30”> Enter your message here
</textarea>
Example 19:
<form>
New Message : <br>
<textarea rows= "5" cols= "50" name= "details">
Compose Your Mail Here...
</textarea>
</form>
c. Radio Button
Radio buttons indicate a list of items, of which only one can be chosen. If one radio
button in a list is selected, all the other radio buttons in the same list are deselected.
Radio buttons
d. Checkbox
Checkboxes makes it possible to choose multiple items in a list. Each checkbox can be
either checked or unchecked.
Example 21:
<Input Type= “checkbox” Name= “Red”> Red
<Input Type= “checkbox” Name = “Green”> Green
<Input Type = “checkbox” Name = “Blue”> Blue
e. Select box
Select has the ability to create pull-down menus and scrolling lists. Selection enables to
select one or more items for a menu on a scrolling list. They’re similar in functionality
to radio buttons or checkboxes, but they’re displayed in a different way on-screen. The
<select> tag and individual options within the selection indicated by the <option> tag
are used for creating such elements.
Example 22:
<HTML>
<HEAD>
<TITLE> Working With Select box </TITLE>
</HEAD>
<BODY BGCOLOR="#aabbcc">
<form>
<P> <b> Select a Country:</b>
g. Reset Button
The Reset button is used for renewing the elements of the form. It allows the client to
fill new entries by clicking on the reset button.
<input type = “reset” value = “reset”>
Example 24:
<form>
<input type= "submit" name= "submit" value= "Submit">
<input type= "reset" name= "reset" value= "Reset">
</form>
<p style=“color: #ff0000; font-weight: bold”> Some text that is red and bold </p>
CSS in itself has no meaning unless it is associated with HTML elements or tags. CSS
is defined as a rule of styles associated with a certain element or set of elements of a
HTML document.
According to W3C, “CSS is the language for describing the presentation of Web pages,
including colours, layout, and fonts. It also allows adapting the presentation to different
types of devices, such as large screens, small screens, or printers.”
As said in the definition, CSS can be defined in such a way that it can change layout,
colors, fonts or any other styles based on the size of the screen (PC Screen, tablet screen
and mobile screen) or for printers. In a desktop computer, screen size is large whereas
in mobile screen size is small and accordingly HTML content should be presented to
webpage viewers. CSS is used to define this type of presentation. If a viewer is trying
to print a web page, the presentation of the page can be made different using CSS to
make it printer-friendly.
CSS Syntax:
<STYLE Type = “text/css”>
Tag {attribute:value; attribute:value…}
•
•
•
</STYLE>
Example 1:
<!DOCTYPE html>
<html>
<head>
<title>My First CSS Try</title>
158 Computer Science : Grade 9
<style>
h1{
color: blue;
background-color: yellow;
border: 1px solid black;
}
p{
color: red;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>This is my first CSS example </p>
</body>
</html>
CSS Properties
At its most basic level, CSS consists of two building blocks:
Properties: Human-readable identifiers that indicate which stylistic features (e.g. font,
width, background color) you want to change.
Values: Each specified property is given a value, which indicates how you want
to change those stylistic features (e.g. what you want to change the font, width or
A property paired with value is called a CSS declaration. CSS declarations are put
within CSS Declaration Blocks. And finally, CSS declaration blocks are paired with
selectors to produce CSS Rulesets (or CSS Rules). Each property has a specific list of
valid values defined for it.
Selectors
In CSS, selectors are used to target the HTML elements on our web pages that we want to
style. Selectors are one part of a CSS rule and come just before CSS declaration blocks.
There are many different types of selectors. For our purpose, we will only introduce
simple selectors that directly match one or more elements of a document, based on the
type of element, class, or id.
i. Inline CSS
ii. Internal CSS
iii. External CSS
i. Inline styles
Inline styles are CSS declarations that affect only one element, contained within a style
attribute:
Example 2:
<!DOCTYPE html>
<html>
<head>
<title>My CSS experiment</title>
</head>
<body>
<h1 style="color: blue;background-color: yellow;border: 1px solid black;">
Good Morning Class!
</h1>
<p style="color:red;">This is my first CSS example of Inline styles </p>
</body>
</html>
These properties might not be immediately intuitive but aren't too difficult. Suppose
we have an element on the page (like a <h2> Element Contents </h2>). Here are the
parts of its “box” when drawn:
ul{
margin: 0em;
padding: 0em;
em - The current font size: if the current text is 12 point then this will be 12 points.
Another unit, an ex is half the text size.
px - One screen pixel (dot) on the display. (Note: for some very high-resolution devices,
real “pixels” are very small, so this length is adjusted to be close to the size of a pixel
on a traditional display.)
mm - A millimeter. There are also units for centimeter, inch, etc. (Note: this is the
browsers best guess, but might be inaccurate depending on the scaling of the display/
projector/phone/etc. For example if you display your screen on a projector, the
“millimeter” suddenly becomes much larger.)
Example 5:
Here is an example page that we can style with some of the properties above:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title> CSS Properties </title>
<link rel="stylesheet" href="css-prop.css" />
</head>
<body>
<h1> CSS Properties </h1>
Exercises
1. State whether the following statements are True or False.
a. HTML is a high-level programming language.
b. HTML supports 6 different levels of headings.
c. The first page of the website is known as the homepage.
d. HTML tags are of two types:
Paired Tags
Singular Tags
e. SIZE can take values between 1 and 7.
f. .gif files are specified with BGCOLOR attribute.
g. The tag used for inserting spaces in the HTML document is <MARKER>.
h. Ordered lists are used for the bullet.
i. START alters the numbering sequence in the middle of an ordered list.
j. HTML allows only static text to be displayed on the page.
k. “ALIGN=LEFT” indicates the image is aligned to the left with respect to
the screen.
l. SRC takes the name of an image file to be displayed as a parameter.
m. HTML allows linking to other HTML documents as well as images.
n. The vertical or the horizontal alignment for every cell in a given row is
Activities
1. Design a web page having the following specifications.
• The italic tag
2. Design a web page using the image files according to the following
specifications.
• Use a Border for Image
• Resize the Width and Height of the image to 100 pixels each.
• Departure Airport
• Destination
• Fare
4. Design website for your school having the following pages using HTML,
CSS and Photoshop.
Home News & Events
About Us Calendar
Teacher Parents
Activities
Contact US
Photo Gallery
Computer Programming
Computer programming is the process of designing, writing, testing, debugging, and
maintaining the source code written in a particular computer language.
Programmer
A programmer is a person who is involved in the different processes of computer
programming.
Assembler
Translates the program written in assembly language into machine language and vice
versa.
Compiler
Translates the whole program into machine language at once.
System
Development
System Evaluation System Design
Life Cycle
(SDLC)
Implementation Coding
System Testing
v) System Testing
Testing is a process of executing a program with the intent of finding an error and fixing
them. There are two types of errors (bugs) – syntax errors and logical errors.
A syntax error is a violation of the rules of the programming language whereas the logic
error has occurred when the programmer has used an incorrect calculation.
Testing is primarily divided into two types White Box Testing and Black Box Testing.
Pseudocode:
Pseudocode is the method in which we begin to write the step necessary to accomplish
the task with short English statements. These codes are not ready to be used because
they are not standardized as an algorithm.
Example:
Pseudocode to calculate the sum of any two numbers
Start Program
Enter two numbers, A, B
Add the numbers together
Print Sum
End Program
Algorithm:
An algorithm is a precise rule (or set of rules) specifying how to solve a specific problem
infinite number of steps. A good algorithm should:
Be language independent.
Be simple, complete, unambiguous and step-wise.
Have no standard format or syntax.
Be helpful to understand problems.
Example 1:
Algorithm to calculate the sum of any two numbers
Step 1: Start
Step 2: Ask any two numbers and stores into a and b
Step 3: c = a + b
180 Computer Science : Grade 9
Step 4: Display c
Step 4: Stop
Example 2:
Algorithm to find the greater number among any two supplied numbers
Step 1: Start
Step 2: Ask any two numbers and stores into a and b
Step 3: Is a>b?
If yes, display a
If no, display b
Step 4: Check more?
If yes, go to step 2
If no, go to step 4
Step 5: Stop
Flow chart:
A diagram of the sequence of operations in a computer program is called flow chart. It
uses few standard symbols. They are:
Process
Process block. Represents process,
3.
formula or function.
Connector
Connector. Used to link to a
5.
segment of the flowchart.
Flow Lines
Flow lines. Used to show the
6.
direction of flow of the program.
Example 1:
Flowchart to find the sum of any two supplied numbers
Example 3:
Flowchart to display the first 10 natural numbers
Exercises
1. Answer the following questions.
a) Define program and programming.
b) What is a programming language? Explain with its types.
c) What are the language processors?
d) Differentiate between Compiler and Interpreter.
e) What is SDLC? Explain the various phases involved in SDLC.
2. Write down the algorithms and draw the flowcharts for the following
programs.
a) To calculate the volume of a room
b) To calculate Simple Interest and total amount.
c) To convert the length of your room from cm to meter
d) To check whether the supplied number is odd or even
e) To display the smallest number among any 3 supplied numbers
3. Write down the single word for the following statements.
a) A step of instructions given to the computer to perform a specific task.
b) The process of designing, writing, testing, debugging and maintaining the
source code of computer.
c) Translates the whole program into machine code at once.
d) Computer language is written in simple English with some mathematical
notation.
e) A step-by-step solution to a problem
f) A graphical representation of a solution to a problem.
g) A flowcharting symbol used while taking decisions.
QBASIC
In Windows XP,
If you are not using QB64, you can download QBASIC from the Internet and
save it in any location inside your computer. For instance, we have saved it in D:
drive with folder name QBASIC.
In Windows 7, 8 or 10
Since the QBASIC is an old
programming language. You cannot
directly open this version of QBASIC like in Windows XP. You need to install an
emulator program like DOSBox.
This is a sample program to display the words “hello world” on the output screen.
QBASIC Shortcuts
Press Alt+F, the sub-menus of “File” menu
will be displayed as in the left-side figure.
You can see several characters in white
colour.
For example:
Press ‘O’ to open an existing file as the
letter ‘O’ is seen in white colour in “Open
Program” sub menu of “File” menu.
Immediate Window
The lower part of the QBASIC editor is called the Immediate window. From this window,
single-line commands and expressions are tested. In Immediate window, as soon as you
press Enter () key, it displays the output on the screen.
Note: To switch between Program window and Immediate window – Press F6 button.
Character Set
Characters from the QBASIC character set are combined to form keywords, variables,
operators and labels. They are further combined to form instructions that make up a
program. The QBASIC character set consists of all alphabetic letters (both uppercase
and lowercase), all digits and some special characters having special meaning to the
basic translators.
#, $,!, %,& They are suffixes used at the end of variable names to specify the type
of variable.
+,-,*,/,\ They are mathematical operators.
<,>,= They are relational operators.
(,) They are parenthesis.
: It is used to write multiple statements in a single line.
A character denotes any alphabet, digit or special symbol used to represent information.
The below table shows the valid alphabets, numbers and special symbols supported
by QBASIC.
Words
These are mainly the following two types:
Reserved words: Words having a special meaning to QBASIC such as the name of the
statements, library functions etc. are termed as reserved words or keywords.
E.g. Statements PRINT, INPUT, LET, CLS etc are reserved words and should not be
used as the name of the variables or functions.
User-Defined words: These are the words used in statements as variables or user-defined
functions. These variables may have different meanings in different programs.
Here, LET is a keyword and is a reserved word while NAME$ is a variable and is a
user-defined word.
(b) Variable
A variable is a small amount of computer memory (RAM) that has been given a name. It
stores the value of a particular data type while the program is being executed. The
(c) Constants
A constant is an entity that doesn’t change, whereas a variable is an entity that may
change.
Example:
a=4
4
a
Since the location whose name is a can hold different values at different times, so a is
known as a variable. As against this, 4 does not change, hence is known as constant.
Types of Constants
Numeric Constant
It has only numbers from 0 to 9. For example: 45,456.35, -44 etc.
Symbolic Constant
A constant whose value remains the same through the whole program is called a symbolic
constant. In QBASIC, CONST statement is used to declare a symbolic constant.
i) Implicit Declaration
In this type of declaration, the type of variable is defined as certain special declaration
characters. We use %,&,!,# and $ symbols to declare the variable type implicitly.
Example:
A$=”Nepal”
Here, we use $ symbol after the variable name A, which indicates the type of variable
is string.
i) Arithmetic Operators
These operators represent arithmetic operations such as addition, subtraction,
multiplication etc.
The hierarchy of operation in BASIC is commonly called as the PEDMAS rule where;
P Parenthesis ()
E Exponentiation ^
D Division /, \, MOD
M Multiplication *
A Addition +
S Subtraction -
AND Operator
An AND operator returns True (1) at its output only when all of the inputs are high (1).
False (0) is returned when one or more of the inputs are low (0).
OR Operator
An OR operator returns True (1) at its output when one or more of its inputs are high
(1). False (0) is returned only when all of the inputs are low (0).
198 Computer Science : Grade 9
NOT Operator
The NOT operator (Inverter) performs the logic function called inversion or
complementation. If the input signal is low then the high output signal is obtained and
vice versa.
A$ = “Visit”
The value of C$ is:
B$= “Nepal”
VisitNepal
C$=A$+B$
(b) Expressions
An expression is a set of variables and constants having a definite value (operands) in
which various mathematical operators are used to show the relationship between the
variables and constants.
Example:
a+b)^2-2*a*b
X$=MID$(A$,N,1)
Types of expression
Algebraic Expression
The expressions that are used in mathematical and other fields are called Algebraic
expression.
Example: S = ut + at2
QBASIC Expression:
The expressions that can be used in QBASIC programs are called QBASIC expressions.
Example: a >= b
I=(P*T*R)/100
(a+b)(a-b) (a+b)*(a-b)
(a/b)*x^2
(c) Operands
Operands are the values on which the operator performs its operation.
C = A+B
The symbols ‘=’ and ‘+’ are the operators and the variables ‘C’, ‘A’ and ‘B’ are the
operands.
a) A = Πr2h b) c)
d) A = 2h(l+b) e) x3+x2y+xy2+y3 f)
g) h) i) (a+b)2 = a2+2ab+b2
j)
Types of Statements
Statements can be categorized into four groups.
→ Declaration Statements
→ Assignment Statements
→ I/O (Input/Output) Statements
→ Control Statements
Example:
REM to find the sum of two numbers
CLS
INPUT "Type any two numbers: "; a, b
PRINT "Sum = "; a + b
END
ii) END statement
You have already used the END statement to terminate your program.
Syntax:
CONST constant name = expression
Here, pi is a symbolic constant and its value remains same as 3.14 throughout the whole
program and cannot be changed.
We have discussed about explicit declaration of variable in previous chapter. Array will
be discussed later on.
Syntax:
DIM variable [AS type]
- type declares the data type of variable (INTEGER, LONG, SINGLE, DOUBLE,
STRING)
Example:
DIM A AS STRING
i) LET statement
Purpose: To assign a value to a variable.
Syntax:
[LET] variable=expression
Example:
LET A = 200
C$ = “SCHOOL”
Here, A is a numeric variable and the value 200 is assigned to A. Similarly, C$ is a string
variable and the value “SCHOOL” is assigned to C$.
Note: In QBASIC, a value can be assigned to a variable without LET statement also.
Syntax:
SWAP variable1, variable2
Similarly, the statements that are used to get the result of the processing from the output
device or to the file are called output statements.
i) CLS statement
Purpose: To clear the display screen
Syntax:
CLS
Computer Science : Grade 9 205
Note: It is a good practice to start your every program with CLS statement so that the
previous displayed content will be erased before executing your new program.
Syntax:
INPUT[;]["prompt string"{;|,}]variable list
Syntax:
LINE INPUT[;] ["promptstring";] stringvariable
Syntax:
PRINT [expressionlist][{,|;}]
As a shortcut, use a question mark symbol (?) for PRINT. Try it. Press <Enter> to start
typing on a new line. Now
Type this:
? "Programming is fun."
and press <Enter> again.
PRINT “Nepal”
String literals “Nepal” enclosed in quotation marks is printed.
Syntax:
PRINT USING formatstring; expressionlist[{,|;}]
- formatstring, a string-expression, specifies the format.
# Digit position
- Decimal point position
, Placed left of the decimal point, prints a comma every third digit
$$ Prints leading $
+ Position of number's sign
^^^^ Prints number in exponential format
** Fills leading spaces with *
**$ Combines ** and $
Example:
Statement Output
PRINT USING "##.##"; .12 0.12
PRINT USING "###.##"; 117.614 117.61
PRINT USING "##.## "; 10.2; 5.3; 66.789; .234 10.20 5.30 66.78 0.23
PRINT USING "+##.## "; -68.95; 2.4; 55.6; -.9 -68.95 +2.40 +55.60 -0.90
PRINT USING "**#.# "; 415.4; -.5; 76.14 415.4 *-0.5 *76.1
PRINT USING "$$###.##"; 125.18 $125.18
PRINT USING "**$##.##"; 7.69 ***$7.69
PRINT USING "##.##^^^^"; 758.56 7.59E+02
PRINT USING "####,.##"; 1452.9 1.452.90
Syntax:
READ variablelist
- Variablelist is made up of one or more variables, separated by commas, which
are to receive the data. The variables may be string or numeric.
DATA Statement – a non-executable statement that stores the numeric and string
constants used by a program's READ statements
Sample Programs
1. REM ask name, address & class and display them
CLS
INPUT "Type your name "; n$
INPUT "Type your address "; a$
INPUT "Type your phone "; c
PRINT "Your name is "; n$
PRINT "You live in "; a$
PRINT "You study in class "; c
END
2. REM To find the sum of any two integers
REM Implicit declaration
CLS
INPUT "Type first number "; a%
INPUT "Type second number "; b%
c% = a% + b%
PRINT "Sum = "; c%
END
2. Write down the syntax and use of the following QBASIC statements.
a) SWAP statement
b) CONST statement
c) PRINT statement
d) INPUT statement
e) READ … DATA statement
c) CLS
READ a$
READ c, r
PRINT "Your name is "; a$
PRINT "Your class is "; c
PRINT "Your roll is "; r
READ s$
PRINT "Your section is "; s$
DATA Ramesh
DATA 4
DATA 10,A,5
END
4. Write down the output of the following.
PRINT USING "##.##"; 1.36
PRINT USING "###.##"; 17.614
PRINT USING "##.## "; 187.2
PRINT USING "+##.## "; -168.9
A program is a set of statements. When we run the program, its statements are executed
to perform our tasks. Normally, they are executed one after another from top to bottom.
The order of execution of statements of a program is known as the flow of program or
program control.
Control Structure
Control structures are used to alter the way of execution of the program or used to
control the flow of a program. The controls are classified into three types.
→ Sequential Structure
→ Selection Structure
→ Looping Structure
GOTO statement
Purpose: a control flow statement that branches unconditionally to the specified line
Syntax:
GOTO {linelabel | linenumber}
linelabel or linenumber is the label of the line to execute next. This line must be in the
same procedure or subroutine as the GOTO statement
Example:
CLS
PRINT "Kathmandu"
GOTO abc
PRINT "Birgunj"
abc:
PRINT "Biratnagar"
END
Output:
Kathmandu
Biratnagar
Biratnagar
Here, abc is a linelabel. After displaying “Kathmandu”, the control is transferred to
“abc” and displayed “Biratnagar” bypassing the statement PRINT "Birgunj".
CLS
PRINT "Kathmandu"
GOTO 10
PRINT "Birgunj"
10 PRINT "Biratnagar"
END
Conditional Statement
a) IF .. THEN … ELSE statement
Purpose: It is a control flow statement that allows conditional execution or branching,
based on the evaluation of an expression that must be either true or false.
True
Condition
Statement 1
False
Statement 1
Syntax:
IF booleanexpression THEN [statement1] ELSE [statement2]
Example:
CLS
INPUT “Type your marks”;m
IF m>=40 THEN PRINT “Pass” ELSE PRINT “Fail”
END
Note: statement1 will be executed if the booleanexpression returns true, otherwise
statement2 will be executed.
Syntax:
IF booleanexpression THEN
[statementblock-1]
ELSE
[statementblock-2]
END IF
Syntax:
IF booleanexpression1 THEN
[statementblock-1]
ELSEIF booleanexpression2 THEN
[statementblock-2]
...
ELSE
[statementblock-n]
END IF
Syntax:
SELECT CASE testexpression
[CASE expressionlist1
[statementblock-1]
[CASE expressionlist2
[statementblock-2]
Example:
CLS
n=1
top:
PRINT "Nepal"
n=n+1
IF n <= 5 THEN GOTO top
END
Flowchart of the above program is: Memory table of dry run
Start n OP (Output)
1 Nepal
2 Nepal
3 Nepal
n=1
4 Nepal
5 Nepal
6
Print "Nepal"
The output of the above program is
Nepal
Nepal
Yes Nepal
n <= 5?
Nepal
Nepal
No
Stop
The mid-values of a counter except initial and final value in a loop are called intermediate
value and the final value of a counter is called sentinel value.
Accumulators are the variables in which the intermediate value of another variable is
added.
The above program displays “Nepal” 5 times. When the value of n reaches 6, the given
conditions return true (1) value and the loop will be terminated.
Here, the counter is n and its initial value is 1 and final value is 5 and after each iteration,
the value of the counter will be incremented by 1.
CLS
FOR n=10 TO 2 STEP -2
PRINT “Nepal”
NEXT n
END
If the counter has to be incremented by 1, then you don’t need to specify it with STEP
keyword.
CLS
FOR n=1 TO 5
Nested Loop
A loop inside another loop is called a nested loop.
Program Output
FOR X=1 TO 5 1
FOR Y=1 TO X 12
PRINT Y; 123
NEXT Y 1234
PRINT 12345
NEXT X
Sample Program
i) To check whether the supplied number is prime or not
CLS
INPUT "Type any number "; n
FOR x = 2 TO n - 1
IF n MOD x = 0 THEN c = c + 1
NEXT x
IF c = 0 THEN PRINT "Prime" ELSE PRINT "Composite"
END
Summary
Control structures are used to control the flow of program. There are three types
of control structure: Sequential, Selection and Iteration
In sequential structure, all the statements are executed from top to bottom sequence
without leaving anyone.
In selection structure (also called branching), the control of the program is
transferred from one part of the program to another on the basis of specified
condition or without condition.
In looping structure (also called iteration), statements are re-executed for a definite
number of times.
Exercises
1. Answer the following questions.
a) What is control structure?
b) Define branching statement with its types.
c) What is looping? List the standard looping statements of QBASIC.
ii) CLS
n = 10
top:
PRINT n;
n=n-1
IF n >= 1 THEN GOTO top
END
iii) CLS
c=1
n=5
top:
PRINT n;
n=n*2
c=c+1
IF c <= 10 THEN GOTO top
END
Note: Re-write the programme below using only do…while and DO UNTIL…LOOP
statements
c) CLS
FOR x = 1 TO 3
READ n$, add$, age
PRINT n$, add$, age
NEXT x
DATA "Sushil","Kathmandu",31
DATA "Rajendra",Lalitpur,29
DATA Laxman,Bhaktapur,28
END
d) CLS
n = 15
DO
IF n MOD 3 = 1 THEN PRINT n;
n=n-1
LOOP WHILE n >= 3
END
f) FOR X = 2 TO 15 STEP 2
IF X >= 11 THEN EXIT FOR
PRINT X ^ 2 + 1
NEXT X
PRINT "Done"
END
Types of Function
Basically, there are two types of function available in QBASIC.
→ Library Function
→ User-Defined Function
Library Function
Also called Built-in function or intrinsic function. It is already available with a
programming language. The programmer does not need to define this function.
Syntax:
LEN(stringexpression)
or
LEN(variable)
- stringexpression is a string constant or string expression
- variable identifies the object for which you want the number of required bytes
Example:
CLS
a$ = "Nepal"
b% = 456
Syntax:
LEFT$(stringexpression,n)
- stringexpression is a string constant, string variable, or string expression
- n, a numeric expression, must have a value between 0 and 32,767. If n is zero,
the null string (a zero-length string) is returned.
Syntax:
RIGHT$(stringexpression,n)
v) CHR$ function
Purpose: a string processing function that returns a one-character string whose ASCII
code is the argument
Syntax:
CHR$(code)
- code, a numeric expression that has a value between 0 and 255, is one of the
ASCII character codes
Example:
PRINT CHR$(65) ‘ Displays A
PRINT ASC("abc") ‘ Displays 97
Syntax:
VAL(stringexpression)
Syntax:
STR$(numeric-expression)
Example:
CLS
a=5
b=6
c$ = "7"
Syntax:
SPACE$(n)
- n, a numeric expression that has an integer value between 0 and 32,767, is the
number of spaces you want in the string
Example:
CLS
PRINT "Stand-Up"; SPACE$(5); "Online"
END
x) STRING$ function
Purpose: a string processing function that returns a string whose characters all have a
given ASCII code or whose characters are all the first character of a string expression
Syntax:
STRING$(m,n)
STRING$(m,stringexpression)
xi) DATE$
As a statement
Purpose: To set the current system date
Syntax:
DATE$ = stringexpression
Syntax:
DATE$
- a ten-character string is returned, in the form mm-dd-yyyy
mm is the month (01-12),
dd is the day (01-31), and
xii) TIME$
As a statement
Syntax:
TIME$=stringexpression
Syntax:
TIME$
Syntax:
LTRIM$(stringexpression)
Syntax:
RTRIM$(stringexpression)
Example:
B$ = “ KATHMANDU”
C$ = “BIRATNAGAR ”
B$=LTRIM$(B$)
C$=RTRIM$(C$)
PRINT LEN(B$);LEN(C$)
END
b) Mathematical Function
i) ABS function
Purpose: a math function that returns the absolute value of a numeric expression
Syntax:
ABS(numeric-expression)
Example:
a = -5
PRINT ABS(a)
Syntax:
SGN(numeric-expression)
Syntax:
SQR(numeric-expression)
Syntax:
INT(numeric-expression)
v) FIX function
Purpose: a math function that returns the truncated integer part of a numeric expression
Syntax:
FIX(numeric-expression)
Syntax:
CINT(numeric-expression)
Example:
a=5 a= 5.5 a = -5.5
INT (a) 5 5 -6
FIX (a) 5 5 -5
CINT (a) 5 6 -6
Syntax:
COS(numeric-expression)
Syntax:
TAN(numeric-expression)
Example:
a = 45
PRINT SIN(a)
PRINT COS(a)
PRINT TAN(a)
Syntax:
SPC(n)
- n, a numeric expression that returns an integer value between 0 and 32,767, is the
number of spaces you want in print line
252 Computer Science : Grade 9
Example:
CLS
PRINT "Kathmandu"; SPC(5); "Nepal"
END
Output:
The SPC function returns 5 spaces which are printed as below.
Kathmandu Nepal
Syntax:
TAB(column)
- column, a numeric expression that has an integer value between 1 and (column-
width of the display device )
Note: In normal mode, the column-width of the screen is 80.
Example:
CLS
PRINT "Kathmandu"; TAB(5); "Nepal"
END
Output:
The TAB() function moves the print position to the 5th column of the screen. So, the
string constant “Nepal” will be printed from the 5 columns i.e. after 4 spaces in the
second line as below.
Kathmandu
Nepal
Syntax:
LOCATE [row],[column]
Sample Program
i) To display the reverse of a string
CLS
INPUT "Type your name "; n$
Exercises
1. Answer the following questions:
a) What is a function? Mention its types.
b) What are library functions? List the functions available in QBASIC library.
c) Differentiate between library function and user-defined function.
2. Debug the following programs:
a) REM Reversing a string
INPUT "Type any number "; n$
FOR p = LEN(n$) TO 1
b$ = MID$(n$, 1, p) + b$
NEXT q
PRINT "Reversed = "; b$
END
c) CLS
BROWSER=”BROWSER”
BROWSERLEN$=LEN(BROWSER$)
FOR KOUNTER=1 TO BROWSERLEN
PRINT MID(BROWSER$,KOUNTER,1);
NEXT BOUNCER
END
b) CLS
ST$ = "PLNMPBENPLA"
FOR I = 1 TO 5
READ N
PRINT MID$(ST$, N, 1);
NEXT I
DATA 3,7,9,11,2
END
iv) L v) N E P A L vi) L
A L E P A L A L
P A L P A L P A L
E P A L A L E P A L
N E P A L L N E P A L
Advantages of an Array
→ Array can store multiple values of same data type. So, it reduced the number of
variables.
→ Program will be more efficient and well managed.
→ Sorting and searching the data can be done easily.
Array Declaration
Before using an array, it must be declared. For this, we need to use DIM statement.
Here the array name is N with data-type integer and value of subscript is 5, that is you
can store maximum 5 integers in this array.
45 67 17 32 12
N(1) N(2) N(3) N(4) N(5)
Sample Program
1. REM To find the sum and average of 10 integers
DIM n%(10)
FOR i = 1 TO 10
INPUT "Any integer "; n%(i)
sum = sum + n%(i)
NEXT i
avg = sum / 10
PRINT "Sum = "; sum
PRINT "Average = "; avg
END
Searching data in an Array
Linear search or sequential search
Once the data are stored in an array, we can search a particular data by comparing each
element stored in the array one after another in a sequential order. This type of search
method is called linear search. The search process stops when either the value is found
or the end of the array is encountered.
CLS
DIM n(10)
FOR i = 1 TO 10
READ n(i)
NEXT i
INPUT "Type a number to search"; x
FOR a = 1 TO 10
IF n(a) = x THEN
check = 1
EXIT FOR
END IF
NEXT a
IF check = 1 THEN
PRINT "Data Found!!!"
ELSE
PRINT "Data Not Found!!!"
END IF
DATA 44,34,21,56,76,87,44,51,29,39
END
Sorting data in an Array
Sorting means the arrangement of data in ascending or descending order numerically
or alphabetically. Data can be sorted in various methods like Quicksort, Insertion sort,
Bubble sort, Heap sort, Shell sort etc. But we are using only bubble sort. Normally, we
Bubble sort
Bubble sort is a simple sorting algorithm that works by repeatedly stepping through
the list to be sorted, comparing each pair of adjacent items and swapping them if they
are in the wrong order. The pass through the list is repeated until no swaps are needed,
which indicates that the list is sorted. The algorithm gets its name from the way smaller
elements "bubble" to the top of the list.
Syntax:
DIM array_name(m,n)
Summary
The array is a data structure that holds a collection of data, all of the same type and
accessed using a common name.
Exercises
1. Answer the following questions:
a) What is an array? Write down its advantages.
b) Differentiate between one-dimensional and two-dimensional array.