Computer Science
Grade - 9
Government of Nepal
Ministry of Education, Science & Technology
Curriculum Development Centre
Sanothimi, Bhaktapur
Publisher : Government of Nepal
Ministry of Education, Science & Technology
Curriculum Development Centre
Sanothimi, Bhaktapur
ISBN:
First Edition : 2081 B.S.
Printed at :
Price :
Preface
A textbook is a main tool for the use of students on a particular subject that
is usually developed based on a curriculum to meet its curriculum standards.
This ‘Computer Science, Grade 9’ textbook has been developed to address the
main aims of Secondary Education. It aligns with the intent pursued by the
National Curriculum Framework for School Education, 2076 and has been
developed fully in accordance with the Secondary Level Optional Computer
Science Curriculum, 2080. All components of each lesson in the textbook are
equally important and they have the specific aim of presentation so as to fulfill
the learning outcomes stated in the curriculum.
This textbook is prepared by a team that includes Mr. Sunil Kumar Gharti,
Mr. Bimal Thapa, Mr. Pratik Man Singh Pradhan, Mr. Binaya Adhikari, Mr.
Shyam Adhikari and Mr. Lav Dev Bhatta. Several people notably, the Director
General, Mr. Ima Narayan Shrestha, the subject committee chairperson,
Dr. Bed Prasad Dhakal and the subject committee members; Dr. Bal Krishna
Subedi and MS. Pramila Bakhati contributed a lot in framing the book in this
form. The contribution made by other experts and the practitioners; Dr. Shyam
Prashad Acharya, Mr. Rom Kanta Pandey, MS. Nirmala Pokhrel, Mr. Yub
Raj Adhikari, MS. Salina Dangol and Mr. Shreehari Sharestha is also
appreciated. The language of the book was edited by Mr. Nabin Kumar
Khadka and the layout of the book was designed by Mr. Jayaram Kuikel. The
Curriculum Development Centre extends sincere gratitude to all of them.
This textbook may be used to deliver the foundation for the content of the
curriculum, the balance between theoretical and practical aspects is to be
maintained by the teachers. This textbook can be used as the primary resource
for classroom teaching but teachers are encouraged to make use of their own
resources to supplement the computer science learning of their students. The
Curriculum Development Centre always welcomes constructive feedback for
the betterment of its publications.
2081 BS.
Curriculum Development Centre
Sanothimi, Bhaktapur
Contents
[Link]. Unit Page No.
1. Computer System 1
2. Number System 41
3. Block Programming 53
4. Web Technology 81
5. Internet and Social Media 143
6. Cyber Security and Digital Citizenship 167
7. Concept of Programming 185
Unit 1 Computer System
Figure 1.1
Let’s think!
a) What are the components of a computer system?
o are the computer systems used in a di erent field
c) Which are the major input and output devices of a computer system?
o adays science and technolo y are insepara le from our daily lives he
rapid development of computer technolo y has revolutioni ed the modern orld
omputers are no used orld ide re ardless of a country s development level n
epal computers play essential roles in usiness an in education entertainment
scientific research la and air tra c control omputers have ecome inte ral to
every sphere of human activity rin in a out enormous chan es
echnolo y is at the heart of our e istence omputers serve as essential tools for
accessin information e pressin creativity colla oratin and monitorin learnin
outcomes nderstandin the factors ehind this technolo y ecomes even more
crucial as e uild smart cities
Computer Science , Grade 9 1
1.1 Introduction to computer systems
omputer comes from the atin ord omputare meanin to calculate
o adays computers are every here and are important e use computers at home
school or and other places hey re reat at doin math fast and accurately ut
they can do much more than that hey can ma e documents videos ames music
and presentations
computer is an electronic device that accepts ra data from users processes
ra data accordin to a iven set of instructions and stores and ives meanin ful
information t is a pro ramma le device that can perform specific tas s and enerate
results at a very hi h speed n other ords a computer is an electronic device
operatin under the control of instructions stored in its memory that can accept data
input process the data accordin to specified rules produce information output
and store the information for future use
Features of a computer
omputers are po erful and useful in all areas he uses of computers are ein
increased ith time he main features or characteristics of computers are descri ed
elo
i. Automatic
he computer is an automatic device t can do tas s automatically as instructed
y soft are t can automatically control various devices attached to the
computer system
ii. Speed
computer or s on lo or hi h si nals of electricity hese t o di erent
states of electric si nals are represented on a computer y usin inary num ers
and he circuitry of a computer is desi ned such that electric si nals travel
at the speed of li ht resultin in hi h processin speed t ta es only a fe
seconds for calculations that e ta e hours to complete he eather forecast
that you see every day on is the result of the compilation and analysis of
hu e amounts of data on temperature humidity pressure etc from various
places on computers t ta es a fe minutes for the computer to process the
hu e amount of data and ive the result
t can process millions of instructions or even more in a second
2 Computer Science , Grade 9
he ta le elo sho s the speed of the computer in di erent units of time
Unit of Time Part of Second Power of 10
illisecond ms 1/1000 10-3 ne housandth
Microsecond (μ)s) 1/1000000 10-6 ne illionth
Nanosecond (ns) 1/1000000000 10-9 ne illionth
Picosecond (ps) 1/1000000000000 10-12 ne rillionth
Femtosecond (fs) 1/1000000000000000 10-15 ne uadrillionth
iii. Accuracy
computer performs calculations accurately t is a accurate device
t does not ma e any ind of mista e and does not produce the ron
information ut sometimes due to incorrect input data or instruction or
faults in hard are or pro rams a computer may produce incorrect output
he incorrect output produced due to incorrect input is referred to as ar a e
n ar a e ut n error due to the malfunctionin of hard are or
pro rams is referred to as a u
iv. Storage
computer has stora e capacity t can store a lar e volume of data
information and pro rams on stora e devices li e hard dis s optical dis s
lu ray dis s and ash drives as files hese stora e devices store data
information and pro rams as lon as desired y the user and can e used
henever required he stora e capacities memory si e of stora e devices
are measured in ytes and hi her units of ytes ne yte is needed to store
one character he di erent units of stora e are sho n elo
it or its i le
its yte ytes
eta yte
a yte etta yte
otta yte
Computer Science , Grade 9 3
v. Diligence
computer can perform the tas repeatedly ithout losin speed and accuracy
for a lon time he capa ility of a computer to perform a tas repeatedly
ithout losin speed and accuracy for a lon time is no n as dili ence ue
to this characteristic of a computer it is also called a dili ent machine his
capa ility of the computer ma es it useful for quality control and process
control tas s
vi. Versatile
computer is a versatile machine ersatility refers to the capa ility of doin
various inds of tas s ue to the versatile nature of a computer it is used
in almost all fields t can e used for calculation preparation of documents
desi nin researchin and entertainin t can even e used for transferrin
emails e fa es messa es and files from one computer to another computer
in any place in the orld
Functions of a computer system: Input, Process, Output, Storage (IPOS) with
Basic Block Diagram
computer is an electronic device that converts ra data into meanin ful
information carryin out various processes as instructed y the pro ram he loc
dia ram of the cycle of the computer system as
nput rocess Output
tora e
Figure 1.2
Input: nter data into the computer
Process: rocess data to produce information
Output: isplay information
Storage: tore data and information
4 Computer Science , Grade 9
Application Areas of Computer Systems
ue to the versatile a ilities of a computer it has ecome one of the most important
tools for people eople can perform tas s more quic ly correctly e ciently and
systematically ith the help of computers omputers ma e people e cient and
productive and they also free up their time for other tas s eople are not only
usin computers for preparin documents spreadsheets presentations raphics
etc hey are usin computers for modern facilities li e instant messa in video
chattin email online amin online shoppin tic etin oo in chec in
and transferrin money in an s findin the latest ne s and information etc
o computers are used in nearly every field he follo in are some important
applications of computers
Figure 1.3
Education: Computers are used in
the education sector for teachin and
learnin purposes sin computers
students can learn di erent su ects
throu h e sites on the nternet
eachers can prepare the teachin
materials and present them e ectively
throu h multimedia computers
omputers are also used in education Figure 1.4
for eepin records of students
producin monthly ill statements and results of e aminations
Computer Science , Grade 9 5
Communication: omputers play a vital
role in communication hey help us send
and receive information throu h the nternet
We use various communication services
li e email video conferencin net phone
chattin and social media platforms such
as ace oo itter and nsta ram to stay
connected ith others
Figure 1.5
Banking: Computers have
revolutioni ed the an in sector
hey handle various services li e
accountin updatin customer
records and eneratin an
statements utomated computers
revolutioni e an in y
improvin e ciency security and
customer service throu h online
and mo ile an in advanced Figure 1.6
data analytics and reducin manual processin and costs
Medicine: omputers are essential in
healthcare hey help dia nose diseases throu h
scans li e scans and ultrasounds and monitor
heart health ith tools li e s ospitals
use computers to mana e patient records and
medications and they re even used in sur eries
n addition computers play a crucial role in Figure 1.7
medical research analy in lar e datasets to develop ne treatments and trainin
sur eons ith advanced simulations
Entertainment: omputers are a i part of
entertainment e use them to play ames
listen to music atch films and movies and
even access e stu hey provide immersive
e periences throu h po erful raphics and
virtual reality technolo y treamin platforms
li e et i and potify rely on computers Figure 1.8
6 Computer Science , Grade 9
to deliver a vast li rary of entertainment ocial media platforms connect people
orld ide and computers empo er creativity y ena lin di ital art creation and
innovative product desi n
Scientific research: Computers are
essential in all forms of scientific study
cientists use the nternet to o tain up
to date information from all across
the orld hey rely on computers for
eather forecastin space e ploration
and comple research in various
scientific fields omputers ena le
researchers to analy e vast amounts
of data and conduct simulations that Figure 1.9
further our understandin of the orld around us
Agriculture: omputers have not only
transformed modern occupations but have
also rou ht si nificant chan es in traditional
sectors li e a riculture omputers are
revolutioni in a riculture throu h precision
farmin data driven decision ma in and
advanced technolo ies li e drones o
and enhancin e ciency and productivity Figure 1.10
Activity 1.1
Activity Outcome -
le to descri e computer components features and applications ith
dia rams o charts
Required Resources: hart apers eta ards ard oards ma es o er oint
resentation etc
Procedure:
our teacher ill rea you into roups of and let each roup to present on
one of the follo in topics
omputer eatures omputer omponents omputer pplications
Result: oderated discussion y the teacher for your re ection ith feed ac
Computer Science , Grade 9 7
Exercises
1. Write the full forms of the following abbreviations.
i ii iii iv ms v ns vi s
vii s viii i i
ii scans
2. Choose the correct answer.
a hich fraction of a second is equivalent to one millionth of a second
i illiseconds ii icrosecond
iii) Nanosecond iv) picoseconds
ncorrect input results in incorrect output t is referred to as
i ii iii iv one of the a ove
c o many ilo ytes are in one me a yte
i) 1030 ii) 1000 iii) 1048 iv) 1024
d epeatedly or in capa ility of computers is no n as
i stora e ii speed iii dili ence iv versatility
e hat is the primary function of the in a computer system
i emory stora e ii ata input
iii rithmetic and lo ic operations iv raphics renderin
3. Write short answers to these questions.
a efine the omputer
o do or
c hat is
8 Computer Science , Grade 9
d ist any four computer features
e hy is a computer called a dili ence machine
f ist four computer related uses
dentify distinct computer stora e units
4. Write long answers to these questions.
a plain the or in principles of computers ith a loc dia ram and
e plain it in detail
escri e the use of computers in the education field
Computer Science , Grade 9 9
1.2 Input Devices
nput devices are tools for enterin ra data and instructions into a computer system
hese devices allo users to provide data for processin amples of input devices
include the ouse ey oard oystic microphone etc
Mouse
he mouse is a popular handheld pointin input device
used to interact ith computers t s used for tas s li e
pointin at o ects ivin commands and dra in
or paintin typical mouse has three uttons the left
utton the ri ht utton and the scroll utton sers
employ these uttons for actions such as clic in
dou le clic in ri ht clic in dra in and scrollin
to communicate commands to the computer Figure 1.11
Keyboard
he ey oard is a popular input device used to enter data into the computer y
typin he most common ey oard layout is the ey oard named
after the first si letters in the top ro of eys standard ey oard consists of
eys multimedia ey oard has more than eys he eys on a ey oard are
rouped into five di erent roups as
a lpha et eys
umeric eys
c ursor movement eys
d unctional eys
e pecial purpose eys Figure 1.12
ll eys mar ed ith to and punctuation sym ols are alpha et eys eys
mar ed ith to and mathematical sym ols are numeric eys eys mar ed ith
to are the function eys and they are used for enterin commands eys
mar ed ith arro si ns are cursor movement eys i e also no n
as arro eys and they are used to move the cursor in the specified direction he
pace ar nter ey ac pace ey aps oc ey sc ey trl ey lt ey
hift ey elete ey ome ey nd ey and nsert ey are the special purpose
eys
10 Computer Science , Grade 9
Joystick
oystic is an input device commonly used for playin
video ames t consists of a stic that can e moved
in various directions and typically features additional
uttons for controllin ameplay oystic s come in
di erent types and confi urations tailored for di erent
Figure 1.13
amin e periences
Microphone
he microphone is a device used for capturin sound and
convertin it into a di ital format that can e input into a
computer t is idely used for a variety of reasons includin
voice chat and video conferencin via platforms such as
ype i er ace oo essen er and others
Scanner Figure 1.14
he scanner is an input device used to convert physical
dra in s or documents into di ital format allo in them to
e entered into a computer t functions y capturin ima es
or te t from a physical document and then transferrin this
data to the computer in a di ital format
Webcam Figure 1.15
e cam is a di ital device that captures real time
video and audio essential for video conferencin
online streamin content creation remote or online
education and social interactions
Figure 1.16
Touchscreen
touch screen is a display panel that is sensitive to touch
coverin the screen of a device nitially populari ed in
smartphones touch screens are no commonly found in
laptops note oo s palmtops and des top computers
sers interact ith touch screens y touchin them ith
their fin ers allo in them to select o ects on the screen
and ive commands to the computer system
Figure 1.17
Computer Science , Grade 9 11
Touchpad
touchpad is a touch sensitive pad found in laptops
also called a lide pad or trac pad t acts li e a mouse
lettin users move the cursor y slidin their fin ers t
usually has left and ri ht uttons for clic in
Figure 1.18
1.3 Central Processing Unit (CPU)
he processin unit contains elements such as the entral rocessin nit
also no n as the computer s rain he is the primary processin unit
responsi le for receivin data from the input unit e ecutin instructions provided
y the user and eneratin output information ntel s s pple
s s on pple etc are popular e amples of s
Figure 1.19
Functions of the CPU
he entral rocessin nit performs the follo in primary functions
i. Fetching: he retrieves instructions or data from the computer s memory
ii. Decoding: he interprets the fetched instructions to understand hat
actions are required
iii. Executing: he performs the necessary actions such as calculations
data movement or interactin ith other hard are
12 Computer Science , Grade 9
iv. Storing: he stores the results of e ecuted instructions ac into memory
or sends them to an output device
v. Managing Interrupts: he handles interruptions from other hard are or
soft are ensurin smooth and e cient processin
Components of the CPU: CU, ALU, and MU
he speed of a computer depends mainly on its microprocessor he microprocessor
has three main parts
a ontrol nit
rithmetic o ic nit
c e isters
All these work together to process the computer’s data.
a he ontrol nit controls the or in of all parts of a computer t controls the
movement of data inside as ell as outside the t communicates et een
re isters and the and et een the and all the input output and
stora e devices t directs all the parts of the computer system to perform their
tas s
he rithmetic o ic nit performs all arithmetic operations li e
addition su traction multiplication division and lo ical operations li e
reater than less than not equal etc
c e isters are small memory units used to store immediate data instructions
and results hile processin data
1.4 Motherboard and Data Bus
he mother oard is no n as the rinted ircuit oard or system oard
or main circuit oard t serves as the foundation of the computer system t hosts
various components such as the microprocessor slots ports and other essential
chips ften referred to as the ac one of the computer the mother oard
connects critical components li e the chip net or chip and sound card
ensurin seamless communication and functionality ithin the system
he mother oard serves as a central connector hu in a computer system facilitatin
communication and colla oration amon components
Computer Science , Grade 9 13
i hysical onnections oc ets securely hold ey components li e the and
pansion slots allo for additional hard are li e raphics cards and
net or adapters edicated ports connect e ternal devices such as monitors
ey oards and printers
ii lectrical onnections o er distri ution from the ensures all
components receive po er throu h specific circuits and volta e re ulators
ata transfer occurs via electrical si nals o in throu h the mother oard s
net or of path ays
iii ommunication u hipsets li e the outh rid e and orth rid e mana e
communication et een peripherals and hi h speed components li e the
and nternal uses such as e and act as data transfer
hi h ays et een components
Data Bus
uses are connected lines or electronic path ays ithin a microprocessor chip that
lin its internal components ata address and control are typically three types
of uses in a microprocessor he data us is a ey communication path ay in a
computer system ena lin the transfer of di ital data et een components li e the
memory and peripherals ade of parallel lines it allo s for e cient and
hi h speed e chan e of inary information he idth of the data us measured in
its determines the amount of data transferred in one o ith ider uses typically
o erin faster communication and etter system performance n essence the data
us plays a crucial role in ensurin smooth information o and the e ecution of
computin tas s
The data bus functions as follows:
i ransferrin ata t facilitates the transfer of data et een di erent components
such as the hard drive and peripherals
ii andlin i erent ata ypes arious types of uses mana e di erent inds
of data and operate at varyin speeds
1.5 Computer memory
computer memory is used for storin various types of data and information here
are di erent types of memory for storin data and information ome memory
stores data temporarily and some stores permanently ome memories communicate
14 Computer Science , Grade 9
directly ith hereas some communicate indirectly ith computer systems
he overall classification of computers can e done in t o types
a rimary memory and
econdary memory
Primary memory
rimary memory also no n as the main memory or internal memory of a
computer system serves as the core stora e component t can e cate ori ed as
either temporary or permanent ompared to secondary memory primary memory
has a relatively limited stora e capacity ts primary function is to temporarily store
data and instructions durin processin ctin as the memory directly accessi le
y the primary memory facilitates the processor s interaction ith runnin
applications and services stored temporarily in specific memory locations pon
ootin up primary memory loads all active applications includin the operatin
system user interface and ac round pro rams henever a pro ram or
application initiates ithin the computer system it is loaded into primary memory
to interact ith the operatin system he t o types of primary memory are
andom ccess emory
ead nly emory
RAM (Random Access Memory)
andom ccess emory is the volatile memory or short term memory
of a computer system t e ecutes oth readin and ritin operations t can read
and store data randomly from any physical location ithin it holds data and
instructions durin processin ince it is volatile memory data stored in is
erased hen the po er supply is turned o
ence to retain files permanently they must
e stored on secondary stora e devices li e
a hard dis is classified as read
rite memory since it allo s oth readin
and ritin operations pon po erin on
the system files stored on the hard dis
are loaded into primary memory here
are t o main types of tatic andom
Fig. 1.20 Random Access Memory
Computer Science , Grade 9 15
ccess emory and ynamic andom ccess emory
i. SRAM: tatic andom ccess emory retains data in a static state as lon
as po er is supplied to the memory his semiconductor ased memory
stores data and instructions ithout the need for periodic refreshment unli e
hile is more costly than it o ers faster performance
ypically employed as cache memory consumes less po er compared
to
ii. DRAM: ynamic andom ccess emory is constructed usin capacitors
ata stored in this type of is prone to loss ithin a fe milliseconds even
hen the computer is po ered on necessitatin periodic circuit refreshment
s desi n involves capacitors here char e lea a e occurs hile
is less e pensive and slo er compared to it finds common
usa e in s due to these characteristics
Difference between SRAM and DRAM
SRAM DRAM
a t is made up of transistors a t is made up of capacitors
t is more e pensive t is less e pensive
c doesn t need periodic c needs periodic refreshment
refreshment
d har es don t et lea ed from d ata char es et lea ed from
e are less dense e is denser
f t is faster than f t is slo er than
ata is stored in the form of ata is stored in the form of char e
volta e
ROM (Read Only Memory)
e clusively retains information that can solely e accessed for readin
purposes lterin data stored in presents a challen e ervin as the non
volatile memory of a computer system ensures that data and instructions
remain intact even hen the po er supply is disconnected nli e volatile memory
types doesn t require a constant po er supply to preserve stored data he
16 Computer Science , Grade 9
instructions ithin are em edded durin manufacturin y the respective
manufacturer iven its read only nature users cannot modify the contents of
his type of memory commonly stores asic nput utput ystem
information essential for ootin up the computer he pro rams housed in
are no n as firm are ariants of include and
i. PROM: or ro ramma le
ead nly emory refers to a type
of ith a unique characteristic
it can e pro rammed ust once ut
read multiple times thereafter nce
data and instructions are stored in
they ecome permanent and
cannot e erased imilar to other
types maintains its
contents even when the power is
o nli e hich comes ith Fig. 1.21. Read Only Memory
pre installed contents durin manufacturin is initially lan upon
manufacture o rite data onto a speciali ed device called a
pro rammer or urner is employed nce pro rammed cannot
e altered or erased ma in it suita le for storin permanent data in di ital
electronic devices
ii. EPROM: rasa le ro ramma le ead nly emory is a form
of that o ers the capa ility of ein repro rammed multiple times
o ever repro rammin requires speciali ed techniques involvin
ultraviolet li ht rays he contents stored on can e erased and
re ritten usin these rays t s important to note that frequent erasures of
can lead to ear and tear potentially a ectin its lifespan
iii. EEPROM: lectrically rasa le ro ramma le ead nly emory
is a variation of that o ers the capa ility to erase
and rite data electronically usin electrical si nals ithin a millisecond
nli e traditional does not require special techniques or
la oratory conditions to delete or rite content onto it his e i ility allo s
for the e cient modification of data ithout the need for e ternal tools or
li ht e posure hether it s a sin le yte of data or the entire content of
the device provides the convenience of electrically erasa le and
rita le memory
Computer Science , Grade 9 17
Firmware
irm are refers to soft are that is em edded ithin a piece of hard are n
essence it serves as soft are specifically desi ned to operate and control hard are
components
Cache memory
he hi h speed memory et een primary memory and is no n as
cache memory he cache memory is used to store frequently accessed data and
instruction durin the time of processin y t is the hi h speed volatile
memory availa le to the processor for fast processin he stora e si e of cache
memory is small he first searches data in cache for processin if not found
there then loo s in and loads to cache memory he main importance of cache
memory is to ma e the e ecution faster
CPU register
e ister is a compact stora e memory situated ithin the microprocessor
that is distin uished y its hi h data transfer rate t stores the data and instructions
used y the microprocessor durin its operation
Differentiating between primary and secondary memory.
Primary Memory Secondary Memory
a Primary memory is considered as the a econdary memory is also no n
main memory of a computer system as au iliary or ac up memory
t can directly communicate ith the econdary memory indirectly
communicates ith the
c he stora e capacity of primary c he stora e capacity of secondary
memory is less than secondary memory is hi her than primary
memory memory
d Primary memory is faster than d econdary memory is slo er than
secondary memory primary memory
e hey are more e pensive e hey are less e pensive
f nformation stored in primary f nformation stored in secondary
memory cannot be moved from one memory can be transferred from
place to another one computer to another
18 Computer Science , Grade 9
ata and instructions to e currently ata and information to e stored
e ecuted are stored in rimary permanently are ept in secondary
memory memory
h rimary memory can e oth volatile h econdary memory is non volatile
and non volatile in nature
i rimary emory has faster access time i his memory has lo access time
amples ache amples en drive ard is
Units of memory measurement
he it is the smallest unit of memory measurement representin one inary di it
either or
S. N. Memory Unit Description
it it or
i le i le its
yte yte its
ilo yte ilo yte ytes
e a yte e a yte
i a yte i a yte
era yte era yte
eta yte eta yte
otta yte otta yte
1.6 Storage devices
tora e devices or econdary memory also no n as au iliary or ac up memory
store data and instructions permanently for future use nli e primary memory it
retains information even hen the computer is turned o ommon types include
ma netic tape hard dis s s olid tate rives optical stora e discs and pen
drives
Computer Science , Grade 9 19
Hard disk
hard dis is a popular stora e device that holds enormous
amounts of data indefinitely t is constructed ith aluminum
materials and coated ith a ferroma netic element ts surface
consists of circular metal discs or platters hich rotate hile
data is ritten or read t o ers su stantial stora e capacity
and is measured in revolutions per minute rpm for speed
typically ran in from to rpm
Fig. 1.22
SSD (Solid State Drive)
o adays hard dis s are quic ly ein replaced y
olid tate rive due to their faster performance
lo er latency and increased relia ility s use
semiconductor chips to store data o erin quic er read
and rite speeds compared to hard dis s espite ein
more e pensive s are preferred in devices li e
laptops note oo s and ultra oo s for their enhanced
performance Fig. 1.23
Optical Storage Disc
n optical stora e disc is a disc that uses laser li ht technolo y to store and retrieve
data he most commonly used optical stora e discs are s s lu ray dis s
etc
CD (Compact Disc)
n hilips ompany of the etherland developed the first or optical dis
hich as cm in diameter and had a minute audio video stora e capacity
aser ray technolo y is used to retrieve and store the data he information on the
optical dis is stored in the form of pits hich are tiny re ective umps
is cm in diameter and ei ht m and idth mm millimeter he data
can e ritten on a only once and can e read many times is made up of
polycar on and oth surfaces are coated ith aluminium re ected o adays s
are commonly used in microcomputers t can e used to transfer data from one
computer to another he stora e capacity of is
20 Computer Science , Grade 9
DVD (Digital Versatile Disc)
stands for i ital ersatile isc or i ital ideo isc ts stora e capacity
is hi her than t stores multiple layers of data he various stora e
capacities are
in le ide ayer
in le ide ou le ayer
ou le ayer in le ide
ou le ayer ou le ide
hilips ony oshi a anasonics ompanies developed first in hose
ei ht m rive is used to read rite the data on
Difference between CD and DVD
[Link]. CD DVD
1 ts stora e capacity is ts stora e capacity is up to
2 t is cheaper t is e pensive
3 t is used to store audio and soft are t is used to store video and soft are
4 ts types are etc ts types are etc
5 t as developed y hilips and t as developed y hilips ony
ony oshi a anasonic etc
Flash memory
lash memory is a type of non volatile computer stora e that can e electrically
erased and repro rammed t is a crucial component in various electronic devices
includin drives memory cards s olid tate rives and other stora e
devices lash memory retains stored data even hen po er is turned o
Pen drive
lash memory is a form of non volatile memory
no n for its a ility to retain data even hen po er
is turned o his feature ma es it ideal for stora e
and transferrin data et een personal computers and
various di ital devices ts electronic repro rammin
and erasin capa ility add to its versatility lash
memory is commonly inte rated into ash drives Fig. 1.24
Computer Science , Grade 9 21
players di ital cameras and solid state drives s ata stored in ash
memory is erased in loc s necessitatin the removal of entire loc s efore ne
data can e ritten espite ein more e pensive than traditional hard drives and
ash memory o ers advanta es such as dura ility porta ility and faster
access times hese qualities have contri uted to its idespread adoption in modern
technolo y
Cloud storage
loud stora e refers to the online stora e of data
on remote servers accessed over the nternet
t allo s users to upload access and mana e
their files and data from any here ith an
nternet connection hird party companies li e
rop o oo le rive icrosoft ne rive
and ma on provide cloud stora e services Fig. 1.25
hese services let you chan e the amount of stora e you use loud stora e is
useful ecause you can access it from di erent devices it syncs automatically and
it can e cheaper than traditional stora e methods
Compare HDD Vs SSD Vs Flash memory
ard is rives s have een used for stora e for many years hey use
spinnin dis s and read rite heads to access data his method is relia le and
cost e ective for lar e stora e ut it has slo er speeds usually et een to
s s are ood for storin a lot of data ith si es from to
and they are cheaper per i a yte o ever their movin parts can fail more easily
and are sensitive to physical shoc s hey also use more po er especially hen
startin up o hile s are reat for ac up and storin lots of data they are
slo er than ne er stora e technolo ies
olid tate rives s are a i improvement in stora e technolo y usin
ash memory ith no movin parts his ma es them much faster ith
read rite speeds from s to over s for e s and they
have lo er latency s are more relia le and can handle physical shoc s and
vi rations etter than s hey also use less po er hich is reat for laptops and
mo ile devices o ever s cost more per i a yte althou h prices are oin
do n ue to their speed and performance s are est for runnin operatin
systems soft are and ames
lash memory includes ash drives cards and similar stora e devices
22 Computer Science , Grade 9
hey use ash technolo y hich means no movin parts and lo latency
lash memory devices have di erent speeds and capacities drives can
reach up to s and cards ran e from s to s hey are
very dura le and use little po er ma in them ideal for porta le stora e and
attery po ered devices li e cameras and smartphones lthou h more e pensive
per i a yte than s ash memory is often similar in cost to s and is reat
for quic remova le stora e
1.7 Output devices
utput devices are essential components of a computer system responsi le for
presentin processed data in a meanin ful format to users hese devices convert
di ital information enerated y the processin unit into human reada le forms
he primary output devices include monitors and printers hile other devices such
as plotters spea ers and headphones also serve specific output functions
Monitor
onitors also no n as isual isplay nits s
are essential output devices in computer systems
presentin processed data to users in the form of te t
videos and raphics utput displayed on a monitor s
screen is referred to as soft copy output onitors
come in t o main types ased on color capa ilities
monochrome and color monitors
Fig. 1.26
LED and LCD Monitors
LCD (Liquid Crystal Display) Monitor
monitors utili e liquid crystal technolo y
to display ima es on a screen hey are no n for
their li ht ei ht thin profile and ener y e ciency
hese monitors consist of t o layers of lass or
plastic su strates containin liquid crystals that
form an ima e hen activated ac li htin in
monitors is typically provided y uorescent lamps
Figure 1.27 monitors o er advanta es such as sharp ima e
quality thin desi n and ener y e ciency ma in them popular in various visual
display applications
Computer Science , Grade 9 23
LED (Light Emitting Diode) Monitor
monitors are a type of display technolo y commonly found in modern
monitors televisions and other visual display devices nli e traditional
monitors that use uorescent ac li htin monitors utili e li ht emittin
diodes to illuminate the screen monitors are li hter thinner and more ener y
e cient than cathode ray tu e and monitors hey o er hi her ima e
quality ri htness and color reproduction ma in them ideal for lon term use
Printer
printer is an output device that displays the data or information on the paper
here are mainly t o types of printers hey are impact and non impact printers
Laser printer
aser printers utili e a laser eam to create an ima e on
a photosensitive drum, which is then transferred onto
the paper usin toner po dered in aser printers
are no n for their fast printin speeds and crisp
professional quality prints hey are often used in o ce
environments for hi h volume printin
Fig. 1.28
Ink-jet printer
n et printers use liquid in sprayed onto the paper
to create te t and ima es hey are no n for their
versatility and a ility to produce hi h resolution
prints n et printers are commonly used for
everyday printin tas s such as documents photos
and raphics Fig. 1.29
Dot-matrix printer
dot matri printer is a type of impact printer t features
a print head containin numerous pins hen the print
head stri es an in ed ri on it creates dotted characters
on the paper ot matri printers o er a speed ran e of
to haracters per second
Fig. 1.30
24 Computer Science , Grade 9
3D printer
printers are a unique type of non impact printer that
uilds three dimensional o ects layer y layer usin
various materials such as plastic metal or resin hey
are commonly used in manufacturin prototypin
and desi n industries to create prototypes models
and custom parts printers o er unparalleled
e i ility and customi ation options for creatin
o ects ith comple details
Speaker Fig. 1.31
spea er is a device used for playin sound from computers or other
electronic devices t converts di ital si nals into audi le sound he
quality of the sound e hear depends on the quality of the spea er
itself here are various types of spea ers availa le includin those
desi ned for hi h volume ass or outdoor use
1.8 Peripheral devices
Fig. 1.32
eripheral devices are e ternal hard are components that connect to a computer
or other di ital device to e tend its capa ilities hese devices provide additional
functionalities and interact ith the computer to enhance user e perience eripheral
devices can e cate ori ed into input output stora e communication and other
speciali ed devices hey are essential for the overall functionality and usa ility of
computer systems hey help ith input and output storin data and connectin
to the nternet
Hardware ports
ard are ports are soc ets located on the e terior of
the system unit that lin s to e pansion oards his
architecture facilitates the connection of t o devices
y determinin the desi n of the plu and soc et the
types and purposes of ires involved and the electrical
si nals transmitted across them orts are lin ed to the
interior of the system unit ard are interfaces serve
several ey functions that include
onnectin peripheral devices Figure 1.33
Computer Science , Grade 9 25
rovidin electrical po er to devices ith lo po er requirements li e mice
ey oards and pen drives
ransmittin data to and from peripheral devices
USB port
he niversal erial us is used for short distance di ital
data transfer ports are versatile allo in connection to
a ide ran e of devices such as printers cameras ey oards
spea ers scanners and mice
Figure 1.34
Type C port
he ype port is a versatile connector found in many
devices li e phones and laptops t s small and reversi le
meanin you can plu it in either ay ype supports fast
char in and hi h speed data transfer and can connect to
various accessories Figure 1.35
HDMI
he i h efinition ultimedia nterface is a
common interface for transmittin hi h definition audio
and video si nals over a sin le ca le t is idely used to
connect devices such as di ital s players lu
ay players amin consoles and pple to televisions
VGA port
Figure 1.36
he ideo raphics rray port is a standard
analo interface used to connect monitors pro ectors
and other display devices to computers t uses a
pin connector to carry analo si nals for the red reen
and lue color channels as ell as hori ontal
and vertical synchroni ation si nals espite ein an
older technolo y ports remain prevalent in many
computin environments
Figure 1.37
26 Computer Science , Grade 9
Ethernet port
thernet ports are used for ired local area net or in
ena lin devices to communicate ithin
a net or thernet technolo y defines ho data
pac ets are transmitted over net or ca les and the
protocols used for communication amon net or ed
devices thernet ports typically feature a physical Figure 1.38
connector supportin data transmission usin thernet protocols
Audio port
t is also no n as audio ac s or audio connectors
audio ports are essential for connectin audio devices
such as headphones microphones spea ers and other
audio equipment to electronic devices hese ports
facilitate the transmission of analo audio si nals
et een devices allo in users to listen to audio
output or record audio input Figure 1.39
Activity 1.2
Activity Outcome:
le to descri e disassem lin and reassem lin computers to understand
hard are components y the teacher
Required Resources: omputer ase o er upply nit other oard
entral rocessin nit andom ccess emory tora e
rives ard is rive or olid tate rive raphics rocessin
nit oolin ystems ptical rives optional and pansion ards
Tools needed:
Screwdrivers: ypically hillips head scre drivers of various si es
Anti-static wrist strap: revents static dischar e from dama in components
Tweezers: or handlin small scre s and parts
Thermal paste: sed hen reinstallin a to maintain proper coolin
Plastic pry tools: or ently openin cases or removin components
Computer Science , Grade 9 27
Procedure:
Steps for disassembling
Power off and unplug: nsure the computer is completely po ered do n
and unplu ed
Remove the case cover: se the scre driver to remove scre s and slide o
the cover
Disconnect power supply cables: etach ca les connected to the mother oard
and drives
Remove storage drives and GPU: nscre and carefully slide out
Uninstall RAM: ress the clips on either side of the to release
Remove the CPU cooler and CPU: nscre the cooler and lift it o then
unloc and remove the carefully
Detach the motherboard: nscre it from the case and lift it out
Steps for Reassembling
Place the motherboard: li n it ith stando s in the case and scre it in
Install the CPU and cooler: lace the in the soc et apply thermal
paste and attach the cooler
Install RAM: nsert it into the slots and press until the clips loc
Reinstall the GPU: lide it into the e slot and secure it
Reconnect storage drives: lide them into the ays and connect po er and
data ca les
Connect power supply cables: ttach to the mother oard and components
Reattach the case cover: ecure the cover ith scre s
Result: oderated discussion y the teacher for your re ection ith feed ac
28 Computer Science , Grade 9
Exercises
1. Write Full forms of the following abbreviations:
i ii iii iv v
vi vii viii i
i ii iii iv v
vi vii viii i
i ii iii iv v
vi vii viii rpm i
i ii iii iv
v ps vi vii
2. Choose the correct answer.
i hat is the primary function of the in a computer system
a emory stora e ata input
c rithmetic and lo ic operations d raphics renderin
ii hich of the follo in is a volatile memory in a computer system
a ard is rive
andom ccess emory
c olid tate rive
d ache emory
iii hat does the term stand for in a computer system
a asic nput utput ystem inary nput utput ystem
c ase nput utput oft are d asic nte rated peratin ystem
iv hich of the follo in is a secondary stora e device
a
c lash rive d ache emory
Computer Science , Grade 9 29
v hat is the role of the mother oard in a computer system
a ana e po er supply
onnect all hard are components and provide communication
between them
c ecute soft are applications
d tore data permanently
vii hat is the role of a monitor as an output device in a computer system
a onitors capture and decode arcodes
onitors provide a visual display of di ital information such as te t
ima es and videos
c onitors re ulate the po er supply to other output devices
d onitors convert hand dra n s etches into di ital format
viii hat is the role of microphones as an input device in a computer system
a icrophones capture and decode arcodes
icrophones record audio input allo in for voice commands or
communication
c icrophones read information from ma netic stripes
d icrophones are used for scannin documents
i hat is the primary function of a printer as an output device
a onvert printed or hand ritten te t into di ital form
isplay raphics on the screen
c roduce a hard copy of di ital documents or ima es
d ecord audio input
hat is the primary function of a microprocessor in a personal computer
a isplay raphics on the screen
ana e po er supply to peripherals
30 Computer Science , Grade 9
d ecute instructions and perform calculations
d ontrol the coolin system
3. Write short answers to these questions.
a hat is the primary function of the in a computer system
plain the di erence et een and in terms of functionality
c o does a hard drive di er from in terms of data stora e
d hat is the role of a mother oard in a computer system
e plain the concept of cache memory and its importance in
performance
f efine the term us in the conte t of computer architecture
hat is the purpose of an input device in a computer system rovide
e amples
h hat is a peripheral device and ho does it enhance a computer system
4. Write long answers to these questions.
a plain the architecture of a computer system detailin the functions of
the memory input output devices and stora e
hat is the role of an operatin system in mana in and coordinatin the
various components of a computer system ith e amples naly e the
functions of an operatin system
c i erentiate et een primary and secondary memory
d escri e the role of cache memory and stora e devices o do
they contri ute to overall system performance
e plain the architecture of a in detail
Computer Science , Grade 9 31
1.9 Computer Software
omputer soft are refers to a set of instructions pro rams or data that ena le
a computer to perform specific tas s or functions t is a crucial component of a
computer system or in in con unction ith hard are to provide a platform for
various applications and user interactions omputer soft are is classified into t o
types hey are
a ystem soft are
pplication soft are
a. System software
ystem soft are serves as the ac one of computer operations overseein
and supportin its functions t acts as a vital rid e et een users and
computers servin as a foundation for runnin di erent applications t also
plays a crucial role in or ani in files and folders
ystem soft are is crucial for ensurin computers operate smoothly t
encompasses a ran e of pro rams and tools essential for asic tas s hard are
resource mana ement and maintainin a relia le computin environment
t can e further cate ori ed into operatin systems utility soft are device
drivers and lan ua e processin soft are etc
Figure 1.40
32 Computer Science , Grade 9
i. Operating system
peratin system soft are
is the system software
that controls and mana es
the overall operation of a
computer ust li e a tra c
policeman controls the tra c
on the road t is the asic
requirement of a computer
t is the first soft are that Figure 1.41
is loaded into the computer memory hen you s itch a on and
or s till you shut do n the computer t controls hard are and application
soft are t acts as an interface et een the user and the computer or et een
the soft are and the hard are t ma es hard are usa le in computers and
provides an environment to soft are and users for doin their tas s t provides
the environment in hich you interact ith a computer and application soft are
t is responsi le for the smooth and e cient operation of the computer system
ithout an operatin system in a computer e cannot operate the computer
icrosoft indo s acintosh edora untu ndroid
and are some e amples of operatin systems
ii. Language processor
lan ua e processor also called translator is system soft are that translates
pro rams ritten in assem ly lan ua e or hi h level lan ua e into machine
lan ua e ssem ler interpreter and compiler are three types of lan ua e
processors
iii. Utility software
tility soft are is the helpful soft are that performs specific tas s related to
the maintenance of computer hard are and data t helps to eep a computer
in a smooth functionin condition t provides facilities for performin
tas s li e transferrin data and file recoverin lost data and file searchin
and removin computer viruses dis mana ement etc ac up soft are
o nload ccelerator plit ile nti viruses in ip in a is
efra menter e istry leaner istory leaner learner etc are some
e amples of utility soft are
Computer Science , Grade 9 33
in a learner vira ntivirus
Figure 1.42
iv. Device drivers software
device driver is a set of pro rams
that is desi ned to control and mana e
the specific device he device drivers
ma e the devices usa le very device
or hard are li e printer sound card
display card etc has its o n device
driver uppose you have rou ht a
new printer and to use the printer, you
have to first install the device driver of
the printer
Figure 1.43
b. Application software
pplication soft are refers to pro rams tailored to meet specific user needs
his collection of pro rams is crafted to perform distinct tas s such as
composin emails editin photos creatin presentations listenin to music
en ineerin desi n video editin illin and more ac a ed oft are and
ustomi ed or ailored oft are are t o types of application soft are
i. Packaged/general purpose application software
ac a ed soft are is the readymade soft are developed for all eneral users
to perform their enerali ed tas s oft are companies li e icrosoft do e
rop o orel racle oo le etc use to develop pac a ed soft are
ce do e n esi n y ase erver racle orel ra do e
hoto hop a aya edia layer oo le eet oom
potify etc are pac a ed soft are
34 Computer Science , Grade 9
Figure 1.44
ii. Customized/tailored software
Customized (Tailored) software
is the application soft are hich
is desi ned to fulfill the specific
requirements of an or ani ation
o ce or individual t is useful for
the or ani ation o ce or person for
hom it is developed esult Figure 1.45
rocessin oft are ospital ana ement oft are chool ana ement
oft are ill rocessin oft are ir ic et eservation oft are an in
oft are etc are customi ed soft are
Open sources and proprietary software
ased on the accessi ility of source code of soft are there are t o types of
soft are hey are open source soft are and closed source soft are
pen source soft are is a type of soft are that allo s its source code to e pu licly
accessi le t means anyone can vie modify and use the code freely inu
pache udacity pen ce ndroid and others are open source soft are
he close source soft are also called proprietary soft are is a type of soft are
that does not allo its source to e accessed y any others e cept the creator or
the authori ed or ani ation he usually comes ith a license and users are
required to purchase the soft are to use it his leads to hi her costs and restrictions
on the modification and usa ility of the soft are indo s do e hotoshop
i unes icrosoft ce uite uto and many others are
Computer Science , Grade 9 35
Figure 1.46
Differences between Open-source Software and Proprietary Software
Open-source software Proprietary software
pen ource oft are refers to the roprietary oft are refers to the
software in which users can view the software that uses the proprietary and
source code hich is freely availa le closely uarded code sers cannot vie
on the nternet the source code
he code can e copied modified nly the ori inal authors of the soft are
or deleted y other users and can access copy and alter that soft are
or ani ations
pen source soft are is freely roprietary oft are is also no n as
availa le on the nternet or users have icensed or losed ource oft are
to pay a nominal amount of fee to use and users have to uy a license to use
pen ource oft are roprietary oft are
here is very little security ecause roprietary soft are can e fi ed only
anyone can view and modify the source y a vendor as its source code can only
code and ecause of availa ility the be accessed by the person, team, or
source code is open for hac ers to or ani ation ho created it and maintains
practice on e clusive control over it
36 Computer Science , Grade 9
Open source software provides better here is a very limited scope of
e i ility hich means more freedom innovations ith the restrictions and all
hich encoura es innovation
amples ndriod inu ni amples indo s ac do e
i re ce rupal lash layer i unes icrosoft ce
Comparison between the features of system and application software
System software Application software
t is desi ned to mana e the resources of t is desi ned to fulfill the requirements
the computer system li e memory of the end user for performin day to
device process mana ement security day tas s
etc
t is desi ned y ritin pro rams in t is desi ned y usin hi h level
lo level lan ua e li e machine level lan ua e and
lan ua e or assem ly lan ua e
t e ecutes hen the system is po ered t e ecutes accordin to the user s
on and runs until the system is po ered needs t e ecutes hen the user starts
o and terminates hen the user closes it
t is installed on the computer system t is installed as per the user s
at the time hen the operatin system requirements
is installed
t is capa le of runnin independently t cannot run independently ithout
system soft are
t is independent of the application t needs system soft are to e ecute
software,
t is crucial for the e ective functionin t is not e tremely important for the
of a system functionin of the system
Introduction to mobile and web applications
computer pro ram desi ned for a specific purpose is called an app or application
t is commonly installed on smartphones and ta lets for various tas s o ile
soft are includes apps and operatin systems made for mo ile devices li e
smartphones ta lets and smart atches his soft are is desi ned to or ith
features li e touchscreens cameras and mo ile net or s t covers many
Computer Science , Grade 9 37
types of apps such as ames productivity tools social media and navi ation apps
t also includes operatin systems li e ndroid and i hich mana e the device s
hard are and soft are
e applications are soft are pro rams that run on e servers and are used throu h
e ro sers over the internet nli e traditional des top applications they don t
need to e installed on your device ou use them throu h a e pa e interface
amples include email services li e mail online o ce tools li e oo le ocs
and social media sites li e ace oo e applications are convenient ecause you
can use them on any device ith a e ro ser and an internet connection
Figure 1.47
Activity 1.3
Activity Outcome:
le to descri e the main o ectives of soft are
equired esources hart apers eta ards ard oards ma es o er oint
resentation etc
Procedure:
our teacher ill divide you into a roup of each and let your roup collect
names of soft are used in hospitals hotels the educational sector and other
di erent sectors surroundin you resent and discuss in roup a out the main
o ectives of this soft are
Result: oderated discussion y the teacher for your re ection ith feed ac
38 Computer Science , Grade 9
Exercises
1. Write the full forms of the following abbreviations:
i ii iii iv v
vi vii viii i
2. Choose the correct answer.
i hat is the purpose of an operatin system in a computer system
a ana e hard are resources and provide a user interface
erform comple mathematical calculations
c tore and retrieve data
d isplay raphics on the screen
ii hich type of soft are is desi ned to perform a specific tas such as
ord processin or spreadsheet calculations
a ystem soft are pplication soft are
c tility soft are d irm are
iii hat is soft are
a physical part of the computer
nstructions that tell a computer hat to do
c) A type of input device
d tool for cleanin computer hard are
iv hich of the follo in is an e ample of application soft are
a icrosoft ord c ard rive d
v hat is the role of the operatin system
a o provide po er to the computer
o mana e hard are and soft are resources
c o store data permanently
d o print documents
Computer Science , Grade 9 39
vi hich of the follo in is not soft are
a ey oard e ro ser
c ideo layer d ord rocessor
3. Write short answers to these questions.
a hat does the term open source mean in soft are
o does open source soft are di er from proprietary soft are
c hat is system soft are and hat role does it play in a computer system
d efine application soft are and provide e amples of common applications
e hat is the purpose of utility soft are and ive e amples of utilities
4. Write long answers to these questions.
a plain the types of computer soft are ith their respective functions
i erentiate et een system soft are and application soft are ith
respective roles in a computer system
c i erentiate et een open source and proprietary soft are models ith
e amples of everyday applications that e use
d plain the concept of utility soft are and its role in enhancin the
performance and functionality of a computer system
Project Work
ollect names of soft are used in the hospital hotel educational sector and
other di erent sectors surroundin you and roup discussion a out the main
o ectives of these soft are
a e a short intervie ith your teachers friends parents and relatives and
prepare a field report a out hat types of computers laptops or other devices
they are usin hat types of peratin ystem the device installs lso ma e
a list of apps that they have used in their smartphones
arry out a practical tas involvin the assem ly and disassem ly of a computer
system and rite a detailed report documentin each step of the process
40 Computer Science , Grade 9
Unit 2 Number System
Figure 2.1
Let’s think!
a hat is a di it hat is a computer ord
efine the ase or radi of the num er system
c hich lan ua e is used y computer systems smartphones and ta lets
he concept of num ers evolved lon a o in human history hen people started
usin their fin ers stic s pe les nots of rope and di erent sym ols for countin
ith simple addition or su traction ver time people invented various calculatin
devices t present e use di erent inds of num ers every day for di erent
purposes
2.1 Concept of number system
hese num ers elon to di erent num er systems hich have di erent sym ols
and rules num er system is a ritin system ith specific sym ols and rules for
e pressin num ers and doin di erent calculations or e ample hen e count
thin s e use the decimal num er system hich has sym ols from to
hat means e can ma e any num er e ant usin the sym ols he decimal
num er system is easy to use and understand o it is the most commonly used
num er system in our daily life
Computer Science , Grade 9 41
arious num er systems are currently in use num er system is di erentiated y
its ase or radi he ase is defined as the total num er of di its availa le in the
num er system here are mainly four types of num er systems
ecimal num er system
inary num er system
ctal num er system
e adecimal num er system
Decimal number system
he decimal num er system is the common num er system e use in our lives t
has a ase of since it uses di its ran in from to n this system each di it s
position represents a distinct po er of hich includes units tens hundreds
thousands and so on or e ample the decimal num er consists of the di it
in the units position in the tens position and in the hundreds position
(719)10
2 1 0
)
Binary number system
he inary num er system uses only t o di its and hus it is a ase num er
system t is used y computers or e ample 2
is a inary num er
42 Computer Science , Grade 9
Octal number system
he octal num er system is the ase num er system that uses di its to
ome e amples of octal num ers are 8
, (5706)8, (601022)8 etc
Hexadecimal number system
he he adecimal num er system is the ase num er system that uses sym ols
ie di its and letters he letters from
to represent the values to respectively ome e amples of octal num ers
are (8F5)16, (AC4)16 16 16
etc
e adecimal 0 1 2 3 4 5 6 7 8 9 A C F
ecimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Number system chart
he follo in num er system chart sho s the ase values and the di its of di erent
num er systems
Number system Base Symbols / Digits Used
inary 2 0, 1
ctal 8 0, 1, 2, 3, 4, 5, 6, 7
ecimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
e adecimal 16 and
Application of number system conversion
um er system conversion is important in many fields especially in computer
science and di ital technolo y omputers use inary code to process information
so it s essential to understand ho to convert et een inary decimal octal and
he adecimal systems n di ital lo ic desi n circuits and components use inary
and he adecimal notations ma in these conversions necessary addresses
in net or in are often sho n in he adecimal or dotted decimal notation so
no in ho to convert them is useful um er system conversion is also used in
crypto raphy raphics and si nal processin to represent data e ciently verall
understandin num er system conversion is crucial for anyone or in ith di ital
information
Computer Science , Grade 9 43
2.2 Binary calculation
here are four main types of inary calculation
i inary addition
ii inary su traction
iii inary multiplication and
iv inary division
Binary addition
inary num ers can e added in the same ay as e add decimal num ers he
rules for addin inary num ers are
A
0 0 0
0 1 1
1 0 1
1 1 0 with carry 1
ie
Steps of binary addition:
tep li n the num ers that you have to add in the same ay you ali n hile
addin decimal num ers
tep tart ith the t o num ers from the ri ht end position
tep dd the num ers y follo in the rules of inary addition as iven a ove
tep fter addin the first column from the ri ht position add a second column
and so on
tep epeat the a ove steps until all the columns are finished
amples of inary addition
1 1 0 0
10 0 0 1
ence
44 Computer Science , Grade 9
Binary subtraction
inary num ers can e su tracted in the same ay as e su tract decimal num ers
he rules for su tractin inary num ers are
A
0 0 0
1 0 1
1 1 0
0 1 ith orro in
from the left column
Example:
1 0 1 1 1
-1 0 1
1 0 0 1 0
ence
2.3 Number conversion
eople commonly use the decimal num er system in their daily lives omputers
use inary octal and he adecimal num er systems accordin to their model or
rand e cannot easily understand inary num er systems this ay computers
can t understand decimal num er systems o there are di erent methods to convert
one num er system to another as follo s
Decimal to Binary, Octal, Hexadecimal
ecimal to inary num er system conversion
o convert decimal num ers to inary num ers follo the follo in steps
tep ivide the iven decimal num er y and rite do n the remainder
tep ivide the quotient y and a ain rite do n the remainder
tep epeat the process until the quotient ecomes ero
tep rite the remainder from ottom to top
Computer Science , Grade 9 45
Example: (46)10 = (?)2
2 46 emainder
2 23 0
2 11 1
2 5 1
2 2 1
2 1 0
0 1
herefore 10 2
Decimal to Octal number system conversion
o convert decimal num ers to octal num ers follo the follo in steps
tep ivide the iven decimal num er y and rite do n the remainder
tep ivide the quotient y and rite do n the remainder
tep epeat the process until the quotient ecomes ero
tep rite the remainder from ottom to top
Example: (345)10 = (?)8
8 345 emainder
8 43 1
8 5 3
0 5
herefore 10 8
Decimal to Hexadecimal number system conversion
o convert decimal num ers to he adecimal num ers follo the follo in steps
tep ivide the iven decimal num er y and rite do n the remainder
tep ivide the quotient y and rite do n the remainder
tep epeat the process until the quotient ecomes ero
tep rite the remainder from ottom to top
46 Computer Science , Grade 9
Example: (88)10 = (?)16
16 88 emainder
16 5 8
0 5
herefore 10 16
Binary, Octal, Hexadecimal to Decimal
Binary to Decimal number system conversion
o convert inary num ers to decimal num ers follo the follo in steps
tep ultiply each inary di it ith its place value positive po ers of t o
that is 20, 21, 22, 23, 24
tep dd all the products calculated in step and the total num er is the
decimal equivalent num er
Example: (10011)2 10
(10011)2 4 3 2 1 0
Octal to Decimal number system conversion
o convert an octal num er to a decimal num er follo the follo in steps
tep ultiply each octal di it ith its place value positive po ers of ei ht that
is 80, 81, 82, 83, 84
tep dd all the products calculated in step and the total num er is the
decimal equivalent num er
Example: (157)8 = (?)10
(157)8 2 1 0
Computer Science , Grade 9 47
Hexadecimal to Decimal number system conversion
o convert he adecimal num ers to decimal num ers follo the follo in steps
tep ultiply each octal di it ith its place value positive po ers of t o that
is 160,161, 162,163, 164
tep dd all the products calculated in step and the total num er is the
decimal equivalent num er
Example: (1AC)16 = (?)10
(1AC)16 2 1 0
Note:
H H
Decimal Hexadecimal Octal Binary
0 0 0 0
1 1 1 1
2 2 2 10
3 3 3 11
4 4 4 100
5 5 5 101
6 6 6 110
7 7 7 111
48 Computer Science , Grade 9
8 8 1000
9 9 1001
10 A 1010
11 1011
12 C 1100
13 1101
14 1110
15 F 1111
Binary to Hexadecimal and vice versa
inary to e adecimal num er system conversion
o convert inary num ers to he adecimal num ers follo the follo in steps
tep rran e inary di its in roups
of four from ri ht to left
tep rite the respective he adecimal
num er for each inary roup
tep ive the result ase
Example: (100000110101)2 = (?)16
1000 0011 0101
i it om ination 1000 0011 0101
ctal um er 8 3 5
herefore 2 16
Hexadecimal to Binary number system conversion
o convert he adecimal num ers to inary num ers follo the follo in steps
tep rite inary equivalent di its roup to
each he adecimal num er
tep ive the result ase
Example: (9A3)16 = (?)2
e adecimal num er 9 A 3
inary equivalent 1001 1010 0011
herefore 16 2
Computer Science , Grade 9 49
Activity
Activity Outcome -
le to descri e num er systems and inary calculations ith dia rams
o charts
Required Resources: hart apers eta ards ard oards ma es o er oint
resentation etc
Procedure:
our teacher ill divide you into a roup of each and let your roup present
on any of the follo in topics
a num er system conversion
inary calculation
Result: oderated discussion y the teacher for your re ection ith feed ac
Exercises
1. Choose the correct option.
i hat is the result of the inary addition
a 2 2
c 2
d 2
ii hen addin t o inary num ers hat is the carryin value in
binary addition?
a c d
iii n inary multiplication hat is the result hen multiplyin any
inary di it y
a c d he ori inal di it
iv hat is the ase of the octal num er system
a c d
v hat is inary equivalent to the octal num er
a 2 2
c 2
d 2
vi n the he adecimal system hat does the sym ol represent
a c d
50 Computer Science , Grade 9
2. Answer these questions.
a) What is a number system?
efine the ase or radi of the num er system
c ist out the di erent types of num er systems
d hat is a he adecimal num er system rite do n the sym ols used in
the he adecimal num er system
3. Calculate the following as indicated:
a. Perform the following binary addition:
i 2 2
ii 2 2
iii 2 2
iv 2 2
v 2 2
vi 2 2
vii 2 2
viii 2 2
b. Perform the following binary subtraction:
i 2
- (1001)2 ii 2
- (110)2
iii 2
- (1010)2 iv 2
- (10011)2
v 2
- (10110)2 vi 2
- (10100)2
vii 2
- (1110)2 viii 2
- (10101)2
4. Convert the given numbers as indicated:
a. Decimal to Binary Conversion
i 10
ii 10
iii 10
iv 10
v 10
vi 10
vii 10
viii 10
i 10
10
b. Binary to Decimal Conversion
i 2
ii 2
iii 2
iv 2
v 2
vi 2
vii 2
viii 2
i 2
Computer Science , Grade 9 51
c. Decimal to Octal Conversion
i 10
ii 10
iii 10
iv 10
v 10
vi 10
vii 10
viii 10
i 10
10
d. Octal to Decimal Conversion
i 8
ii 8
iii 8
iv 8
v 8
vi 8
vii 8
viii 8
i 8 8
e. Decimal to Hexadecimal Conversion
i 10
ii 10
iii 10
iv 10
v 10
vi 10
vii 10
f. Hexadecimal to Decimal Conversion
i 16
ii 16
iii 16
iv 16
v 16
vi 1
vii 16
viii 16
g. Binary to Hexadecimal Conversion
i 2
ii 2
iii 2
iv 2
v 2
vi 2
vii 2
viii 2
h. Hexadecimal to Binary Conversion
i 16
ii iii iv
v 16
vi vii viii
52 Computer Science , Grade 9
Unit 3 Block Programming
Have you ever wondered how apps
li e oo le lassroom uolin o
or educational ames li e ode
om at are created hile traditional
pro rammin requires ritin comple
lines of code loc pro rammin
ma es codin as simple as snappin
to ether pieces of a pu le
Figure 3.1
Let’s think!
a hat do you thin is easier solvin a pu le or ritin lines of code hy
an you uess ho loc pro rammin mi ht help us create educational tools
or fun learnin ames
an loc pro rammin e employed to create an educational ame or
simulation that teaches users a out disaster readiness response strate ies and
resilience uildin techniques
n our rapidly advancin orld more and more people are ettin access to
computers hese computers help us do all sorts of thin s li e oin online and
usin di erent pro rams such as ord cel otepad hotoshop etc ut have
you ever ondered ho ames or and ho a esome ad ets li e smart atches
operate ell it s all ecause of pro rammin ro rammin is li e ivin
instructions to computers to ma e them do all the ama in thin s e see and use
every day earnin pro rammin lets you understand ho computers or and
ho to ma e them do hat you ant hat s hy pro rammin is such a valua le
s ill to have in today s orld
ave you ever had a super cool idea for a ame or a ad et ut felt lost on ho to
rin it to life on t orry you re not alone tartin ith pro rammin can feel
li e steppin into a ne orld ith lots of tric y stu to learn t s li e tryin to
understand a lan ua e ith tons of confusin rules ut there is no need to orry
here is a friendlier and easier ay to et into pro rammin and it is called loc
pro rammin nstead of typin out lon lines of code loc pro rammin lets you
dra and drop colorful loc s to create your pro rams
Computer Science , Grade 9 53
ith loc pro rammin you can ma e all sorts of cool stu li e ames animations
and ad ets ithout ettin lost in complicated code o if you re ready to turn
your ideas into reality loc pro rammin is your ne est friend
Have you ever played puzzles?
o you no loc pro rammin is ust li e solvin pu les
ddin loc s to code ust li e solvin pu les in loc pro rammin e add
loc s of code to pro rams and instruct computers to perform some tas s
3.1 Concept of block programming
loc pro rammin is made up of t o
ords loc and ro rammin
loc s are li e pu le pieces that you
can oin to form a eautiful picture n
the other hand pro rammin is a ay of
ivin human instructions to a computer
or electronic device a out hat they
should do loc pro rammin com ines
oth these elements to provide a user
friendly ay to pro rammin Figure 3.2: Concept of Block programming
loc pro rammin is a popular pro rammin lan ua e made for e inners
especially children to teach them the asics of pro rammin y usin colorful loc s
to uild computer pro rams videos and ames t supports the use of raphics
animation and sound ithout the need to understand comple pro rammin
lan ua es ome e amples of loc pro rammin platforms are cratch loc ly
and nap
Let’s try this!
hich of the follo in is an e ample of loc pro rammin
a loc ly nap c cratch d ll of the a ove
Advantages of block programming
a he users do not need to orry a out synta or rammar li e other pro rammin
lan ua es
he users have more time to focus on creativity uildin lo ic and their a ility
to solve pro lems
54 Computer Science , Grade 9
c he chances of human typin error are less since the users do not need to rite
codes
d nli e other pro rammin lan ua es loc pro rammin is colorful visually
appealin and en a in for e inners and children
e loc pro rammin o ers an interactive platform to learn pro rammin
concepts so that the users can easily s itch to te t ased pro rammin in the
future
Applications of block programming
loc pro rammin has many practical applications in various fields due to its user
friendly and accessi le nature ere are some applications of loc pro rammin
a) Educational purpose
loc pro rammin is used in schools
and educational pro rams to teach codin
concepts ts visual approach ma es
pro rammin appealin for e inners t
helps them develop a stron foundation
in pro rammin so that they can easily
transition to te t ased codin lan ua es in
the future Figure 3.3
b) Game development
loc pro rammin is also used to create
ames sers can ma e di erent characters
and elements and uild ame lo ic t
allo s them to focus more on ameplay
lo ic ithout orryin a out comple
codin
Figure 3.4
c) Mobile App development
loc pro rammin can e used to develop mo ile
applications sers can desi n user interfaces define
functionalities and assem le di erent code loc s to
develop ndroid and i apps ithout the need for
comple codin no led e
Figure 3.5
Computer Science , Grade 9 55
d) Robotics
loc pro rammin is also used to pro ram ro otic
devices ts visual pro rammin tools allo users to
desi n movements of ro ots define their ehaviors
and control sensors here are devices li e micro
it and rduino hich can e used ith
loc pro rammin to create ro otic pro ects hile
this provides a learnin platform for students it
also helps them uild creativity and interest in the
Figure 3.6
e perimentation of ro otics pro ects
e) Web development
ith the help of loc pro rammin s visual
interface users can create interactive e sites
hey can define e pa e elements user
interactions and data handlin usin visual
loc s his visual approach acts as a rid e
for individuals to understand e development
concepts efore advancin to traditional te t
ased pro rammin lan ua es Figure 3.7
f) Creative projects
loc pro rammin is also used y artists to
create interactive pro ects li e animations here
are platforms li e cratch and loc ly here
you can find many pro ects created till date
Figure 3.8
g) Modeling and simulation
odelin and simulation is the process of usin
physical or lo ical representation of any iven
system to enerate data and help ma e predictions
a out the system loc pro rammin is a suita le
platform that ma es modelin and simulation easy
y allo in users to define di erent parameters
interactions and scenarios usin visual loc s
Figure 3.9
56 Computer Science , Grade 9
h) Data science and visualization
loc pro rammin can also e used to desi n
al orithms or processes arran e data and
perform analysis of that data usin a visual
interface hose analyses can e visuali ed y
creatin interactive charts and raphs usin loc
pro rammin
Figure 3.10
3.2 Introduction to Scratch
oday s orld is a out technolo y and innovation ore
and more people are ainin access to computers and
di ital devices ur devices ena le diverse tas s from
productivity soft are to creative tools li e hotoshop
ut have you ondered a out the ma ic ehind ames
and ad ets he main thin is pro rammin ivin
computers instructions for incredi le tas s earnin
pro rammin unloc s understandin and empo ers
us to create di ital solutions et s e plore cratch a
popular and user friendly pro rammin platform Figure 3.11
cratch is one of the most popular and idely used loc pro rammin lan ua es
t as developed y ifelon inder arten roup at edia a and is an
open source platform hich means that the soft are is free and pu licly availa le
to everyone t has a lar e and supportive community of users ho share their
pro ects and help each other on the cratch e site cratch is the current ersion
of cratch cratch a real soft are development tool ith a colorful interface and
presentation style t allo s users to create
various thin s includin ames and interestin
ad ets hile ivin them an e perience of
pro rammin ven thou h cratch is fun
and en a in to use users ill face similar
challen es li e a professional pro rammer in
terms of lo ic uildin and pro lem solvin
ith cratch you can also ma e your dream
pro ects such as ames and even controllin Figure 3.12
ro ots or devices a reality
n the iven fi ure you can see a simple pro ram that ma es a cat character move
and say amaste ith the help of cratch
Computer Science , Grade 9 57
n this section e ill learn ho to uild pro rams li e this o ever first let s
learn ho to do nload cratch on your computer
Let’s know more!
iscuss ith your classmates and list out any di erent pro rammin platforms
li e scratch on the concept of loc pro rammin ou can ta e the help of a
teacher
a) b)
c) d)
Downloading Scratch on PC
cratch is availa le for o ine use on your computer o use cratch o ine you
must do nload the cratch application throu h their e site follo in these steps
o to your e ro ser and open the lin https scratch mit edu do nload
Figure 3.13
o nload the cratch installation file nce do nloaded open the e e file
to install the application on your computer
Figure 3.14
58 Computer Science , Grade 9
nce the installation is complete open the cratch application ou ill find
an interface as sho n elo dependin on your cratch version
Figure 3.15
Using Scratch online on PC
ou can also use cratch online on
the internet from the cratch e site
https scratch mit edu nce you are on
the e site clic on reate and start
creatin any pro ects that you ant Figure 3.16
emem er hen usin cratch online
you ill need to create an account to save
your or or share your pro ects ith
others o create an account clic on oin
scratch on the top ri ht corner and fill
your details se the same details to lo in
to your account later
Scratch for mobile.
Figure 3.17
cratch also has a mo ile version for
users ho prefer to create and e plore
pro ects on their mo ile devices o
access cratch on mo ile you can
do nload the cratch app from your
device s app store nce do nloaded
you can open the app and start en oyin
cratch on your mo ile device Figure 3.18
Computer Science , Grade 9 59
Classroom activity: 3.1
s you already learned ho to do nload cratch on oth mo ile phones and
s discuss ith the class hich version of cratch you do nloaded and here
you saved it on oth platforms
Features of Scratch
cratch is a visual pro rammin lan ua e that can e used to implement codin
lo ic t is useful for e inners pro rammers students or content creators cratch
pro rammin helps to develop creative thin in lo ical reasonin and the a ility
to colla orate ith others ere are some of the features of cratch pro rammin
a) Drag and Drop Interface: elps to create code y assem lin loc s
b) Event Driven: espond to events such as clic in dra in or pressin ey
c) Data and Variable: cratch allo s varia les to store and manipulate data
ithin a pro ram
d) Loops and Condition: asily control the o of pro ram e ecution
e) Sounds: llo s the addition of sound and music to enhance pro ect interactivity
f) Community Sharing: ro rammers can use cratch to share their pro ects
ith others allo in everyone to e plore the ama in creations from the
lo al cratch community
Scratch Interface
cratch has a colorful and en a in interface oth
the online and o ine platforms of cratch are the
same he interface has four main components
sta e sprite loc s palette and script area
Figure 3.19
60 Computer Science , Grade 9
a Stage: ou can see the result of your
pro ram in the sta e ou can do so y
clic in on the reen a
Sprite: ach o ect in cratch is called a
sprite y default you et a cat sprite hich
can e chan ed throu h the hoose a
Figure 3.20
prite option
c Blocks palette: he loc s palette is similar
to the paint color palette used y painters
he loc s are represented y di erent
colors hich you can use to pro ram your
sprites
d Scripts area: ou can dra the loc s and
drop it in this area, and connect them with
other loc s to create your o n piece of
code
Figure 3.21
e Extensions library: ou can add additional
features and functionalities to your cratch
pro ram throu h this li rary such as usic
en micro it etc
f Costumes tab: his ta is also called the
paint editor, where you can draw your own
characters or sprite
Figure 3.22
Sound tab: his ta is used for addin sound
e ects to your sprite or pro ect
h Sprite info pane: his portion of cratch
sho s all the sprites added to your pro ect
ou can select hich sprite you ant to
pro ram y clic in the sprite in this section
i File tab: his ta has options to open ne
pro ects load old pro ects as ell as save
pro ects
Figure 3.23
Computer Science , Grade 9 61
Choose a Sprite: his ta allo s you to choose
a di erent sprite from the cratch s in uilt
li rary here are a total of sprites in the
cratch li rary
Choose a Backdrop: ac drop is an ima e
hich can e displayed on sta e his ta allo s
you to choose a ac drop from cratch li rary Figure 3.24
l Project Name: his ta displays the name of
your pro ect ou can simply chan e your pro ect
name y clic in on it
m Green flag: his utton is li e the play utton
for your sprite f you choose the event loc
hen reen a clic ed you need to clic this Figure 3.25
utton to see the output of your code
n Backpack: his portion is a space to add your
loc s hich can e used in di erent pro ects
Figure 3.26
Let’s understand more!
iscuss ho the ori inal sprite that is cat can e chan ed and hat o ect can e
eep instead of cat
Concept of Block
loc pro rammin uses colorful loc s to sho actions or commands ou put
them to ether y dra in and droppin to ma e a list of thin s to do t s li e
playin ith uildin loc s ut you re uildin pro rams his ay of codin
is easy for e inners li e you to understand or e ample to move a character
or ma e it perform an action li e ump simply you can select and connect the
correspondin loc s t helps you e creative and fi ure out pro lem solvin s ills
Assess yourself!
s you already have no led e on scratch interface open scratch and try to
chan e the sprite from cat to any other o ect and create a asic pro ram li e
sayin amaste
se the loo s loc say ello and chan e the value to amaste
62 Computer Science , Grade 9
Component of Scratch
he loc component of cratch is one of the main components hich ma es this
pro rammin lan ua e unique hese are pre pro rammed codes ith unique
functions that are represented in the form of colorful loc si e representation
hese loc s are li e pu le pieces that you can oin to form a eautiful picture
n cratch there are a total of di erent types of loc s availa le in the loc s
pallete hese loc s are rouped to ether as per their functionality and can e used
to control the sprite s ehavior such as
´ otion loc ´ oo s loc ´ ound loc
´ vents loc ´ ontrol loc ´ ensin loc
´ perators loc ´ aria les loc ´ y loc
1. Motion block
his loc ma es the sprite or character move turn
point or lide the sprite on the sta e ou can also set
or chan e the sprite s position direction or rotation
style
Figure 3.27
For example:
efault sprite in the motion loc turn de rees Output of the code
e innin com ined ith an event loc hen is clic ed
hen clic ed
2. Looks blocks
his loc allo s you to chan e the appearance
of the sprite such as its costume color si e or
visi ility ou can also ma e the sprite say or thin
somethin throu h it or e ample
Figure 3.28
Computer Science , Grade 9 63
efault sprite in loo s loc s set color e ect Output of the code
the e innin to 100” and “say Namaste! for 2 hen is clic ed
seconds” combined with with an
event loc hen clic ed
3. Sound block
his loc lets you play stop or chan e the volume
of sounds ou can also ma e the sprite play a note
a drum or a sound e ect or record your o n sound
usin the microphone or e ample
Figure 3.29
sound loc start
sound Meow” combined
ith an event loc
hen clic ed
a es a sound hen is
clic ed
4. Events block
his loc allo s you to tri er the actions in your
pro ect such as hen the reen a is clic ed hen
a ey is pressed or hen a messa e is received or
e ample
Figure 3.30
64 Computer Science , Grade 9
efault sprite in ame pro ram as the first ame output as the first
the e innin e ample ut event loc e ample ut y clic in
hen this sprite clic ed is on the sprite
used
5. Control block
his loc allo s you to control the o of the sprite s
code y repeatin aitin or stoppin ou can also use
conditional statements such as if if else or ait until to
ma e the sprite do somethin only hen a certain condition
is true or e ample
Figure 3.31
control loc sensin loc ey space o outputs of
“if ___ then pressed?” is dropped in “if pro ram hen
else is condition hen loo s loc s clic ed ith and
combined with say ello for seconds and say ithout pressin
event loc Namaste! for 2 seconds” combined “space” on the
hen clic ed in if and else case respectively ey oard
Computer Science , Grade 9 65
6. Operators block
his loc allo s you to perform mathematical
calculations such as addition su traction multiplication
division or random num ers ou can also compare
values such as equal reater less or et een as ell
as com ine or manipulate te t or e ample
Figure 3.32
loo s loc say n operator loc utput of pro ram
ello! for 2 seconds” dra ed and dropped in place displayed hen
combined with an event of default ello parameter is clic ed
loc hen clic ed in the loo s loc
Let’s anwer these questions!
a hat are operator loc s
hat control loc
7. Variables block
his loc allo s you to create and use your o n
varia les to eep trac of scores names levels or
anythin else that chan es durin the pro ect ou can
also use these loc s to set chan e or sho the value
of a varia le or e ample
Figure 3.33
66 Computer Science , Grade 9
varia le loc set my varia le to
is com ined ith a sensin loc as
hat s your name and ait e have
a sensor loc ans er hich ta es the
user input
he varia le parameter is replaced
ith the sensor loc ans er to put the
value in the varia le loc my varia le
he operator loc oin apple anana
is also replaced ith a te t ello and
loc my varia le
ll the loc s are connected to ether to
form this piece of code
he pro ram as s the user to respond and
replies ello name
Let’s check!
hich loc s help you store data
a sensin loc varia le loc c control loc d my loc
8. My blocks
his loc allo s you to create and use custom
loc s you ma e y yourself ou can use custom
loc s to roup to ether a set of loc s that you
ant to use multiple times or to create ne loc s
that perform a specific function or e ample
Figure 3.34
Computer Science , Grade 9 67
Lab activity
reate a pro ram to add the sum of num ers in hich you have to add your o n
loc of code create a loc of code that fulfills the need of the pro ram
o that you have a asic understandin of cratch s components let us try to
uild a ame usin these components
Demonstration: Dustbin Game
Figure 3.35
Step 1: y default you et a cat sprite elete it from the sprite info pane and clic
on hoose a sprite to add ne sprites from the li rary or dra your o n sprite
the dust in
Figure 3.36
68 Computer Science , Grade 9
Step 2: elect the dust in sprite from the sprite
info pane to pro ram ith the code sho n
elo ind these loc s from the loc s palette
and com ine them as sho n ou can find these
loc s y referrin to their color or e ample
hen clic ed is an event loc hich is
yello in color loo loc s li e hide and
sho are purple in color and so on
Figure 3.37
Step 3: o clic on the other sprites i e e s
ottles etc one y one to pro ram them ind the
loc s sho n elo and com ine them ou can
copy and paste the same loc s for other sprites
Figure 3.38
Step 4: ou can also add a ac drop to your sta e from the hoose a ac drop
option
Figure 3.39
Computer Science , Grade 9 69
Step 5: o that everythin is complete you must save your pro ect so that you
can vie it later or share it ith others
f you are usin cratch online ma e sure you have created your account and
lo ed in nce you are lo ed in you should see the ave o option in the top
ri ht corner ust a ove the sta e
Figure 3.40
f you are usin cratch o ine simply clic on ile and save your pro ect as
s e tension for future use
Step 6: o that everythin is completed clic on the and start playin
Activity: 3.1
s e come to the end of the concept of scratch you may have ideas for di erent
ames ut for no let s try to uild a ame eepin the name of the ame
atch the fruit
Game Description: reate a ame here you control a as et to catch fallin
fruits for points se motion loc s to move the as et left and ri ht ith arro
eys se sprites for fruits fallin from top to ottom and event loc s for
random appearances isplay points usin a varia le and sensin loc s a e
it challen in ith speed variations and sound e ects for catchin or missin
fruits
3.4 Concept of Micro Bit
he micro it is also styli ed as micro it is a small device not i er than
your calculator that you can pro ram and create interactive pro ects li e ames
70 Computer Science , Grade 9
ashli hts ro ots ihar li hts etc t is a
tiny computer desi ned for learnin ho
pro rammin and hard are components can
or to ether to create interactive pro ects
he ay of creatin such pro ects to interact
ith the orld is also referred to as physical
computin
History of Micro:bit
Figure 3.41
Do You Know?
icro it is also called icro it and it as developed aimin to encoura e
youn people to e creative di itally and up rade their pro rammin s ills
icro it as developed as a part of an educational initiative in the nited
in dom y the ritish roadcastin orporation in his pro ect as
a collective or of several or ani ations includin the icrosoft
and several educational partners he micro it as desi ned to e a simple and
a orda le device that could introduce students to codin and electronics in a
practical en a in and motivatin ay
Components of Micro:bit
The components that makes physical computing possible are as follows:
a icrocontroller t is a tiny computer that can pro ram the micro it oard to
perform specific tas s
matri t has a rid of li hts that you can use to display te t
num ers ima es or animations
c ensors t has li ht and temperature sensors that measure li ht and temperature
around the micro it oard
d hysical computin hysical computin is a out ma in systems that interact
ith the real orld t com ines hard are li e sensors ith soft are to create
interactive e periences such as ro otics or eara le tech smart atches
fitness trac ers au mented reality lasses and health monitorin devices
e uttons t has t o uttons that you can use to tri er your code hen pressed
Computer Science , Grade 9 71
f icrophone t can send and detect sounds or noises
in connector t has a set of holes that you can use to connect ires or other
components to the micro it
Let’s answer!
icrocontroller is a tiny
a ensor computer c soft are d ll of the a ove
Applications of Micro:bit
here are many applications of micro it in various fields
ome e amples are
Education Figure 3.42
icro it is used as an educational tool to provide hands on codin and electronics
e perience his small device consists of sensors s and ireless capa ilities
hich ma es it ideal for students to create interactive pro ects from ames to cool
ad ets solutions
Fitness
icro it can also e used to ma e fitness ad ets
ue to its small desi n and pro ramma le features
micro it can e used to create interestin fitness
pro ects that promote movement and e ercise ome
e amples of fitness related pro ects usin micro it
are step counter fitness ame or out trac er etc
Figure 3.43
Games
icro it is also an ideal platform to ma e ames
t allo s users to code and create their o n ames
usin di erent uilt in features such as uttons
sensors and s ome e amples of ames are
roc paper scissors ma e and dice simulator
Figure 3.44
72 Computer Science , Grade 9
Fashion
icro it is also used in the orld of fashion ith
a unique com ination of technolo y and style
his small pro ramma le device allo s fashion
desi ners to put interactive elements into arments
accessories and eara les ith the help of uilt in
sensors s and ireless capa ilities Figure 3.45
Music
icro it can e used to create interactive musical
instruments compose electronic eats and
e periment ith di erent sounds t has a uilt in
spea er to play sounds ou can find pro ects li e
a funny voice recorder anana piano and u e o
on micro it s o cial e site
Cooking Figure 3.46
icro it is not specifically desi ned for coo in
applications ut its features can e creatively
used to enhance certain aspects of the coo in
e perience or e ample a di ital e timer a
temperature sensor to chec coo in temperatures
or you can ma e it to display recipes for foods
Home and Garden Figure 3.47
icro it can e used to create smart home
solutions such as temperature and humidity
monitors interactive li htin systems and much
more imilarly micro it can also e used for
smart ardenin y monitorin the moisture of
soil e posure to sunli ht or even automatin
aterin systems
Figure 3.48
Computer Science , Grade 9 73
Do you know?
e can also control micro it devices
throu h cratch pro rammin n
cratch there is an e tension ta
here you can select micro it and
et a ne loc named micro it on
the loc s palette to create physical
pro ects Figure 3.49
3.5. Concept of Arduino UNO
hile micro it is more
suita le for e inners and
educational purposes
rduino is preferred
for a ider ran e of
pro ects such as
ashli hts ro otic vehicles
temperature sensors etc t
is one of the most common
and idely used rduino
oards
Figure 3.50
Fun fact!
he oard ot its name from the talian and panish ord uno meanin
one t s called ecause it s the first and most asic rduino oard
History of Arduino
he rduino platform as developed y t o en ineers avid uartielles
and assimo an i in heir motive as to provide a tool specifically for
students to help them learn pro rammin ith the rduino no microcontroller
and enhance their electronic s ills at the same time heir oal as to encoura e
students to apply their no led e in real orld cases and help develop a practical
understandin of pro rammin and electronics
74 Computer Science , Grade 9
Types of components in Arduino UNO
The components of Arduino UNO can be categorized in two parts: hardware
and software.
a) Hardware
rduino has a microcontroller called me a hich is li e the
rain of this rduino oard t also consists of di ital pins analo pins
a port a po er ac a reset utton a uilt in a crystal oscillator
and a volta e re ulator
b) Software
rduino has a special soft are called rduino his soft are helps
you rite codes for your rduino and sends it to the oard ou can also add
e tra features usin ready made sets of code called li raries
Do you know?
in ercad is a free d modelin pro ram here e can ma e virtual pro ects
ith rduino and simulate the result hile codin e can either use other
pro rammin lan ua es li e ython or e can even code loc s ust li e
scratch and pro ram rduino
Applications of Arduino UNO
he rduino is versatile and easy to use t means that an rduino can
e used in various fields ere are some common applications of the rduino no
a. Education
rduino no is idely used for educational purposes t has a user friendly
interface and is used to teach oth electronics and pro rammin to ether
b. Home
rduino no can e used in home automation
pro ects such as controllin li hts chec in the
temperature and many other appliances
Figure 3.51
Computer Science , Grade 9 75
c. Robotics
rduino no is popular for creatin and testin ro otic devices t can e used
to control motors sensors and other ro otic components
d. Wearable technology
rduino no is a small device hich ma es it suita le for
creatin eara le technolo y devices ou can pro ram
an rduino to ma e devices li e di ital atches step
counters etc
e. Data gathering
Figure 3.52
rduino no can also e used as a source of collectin data ith the help of
various sensors his ma es it suita le for monitorin the environment motion
detection trac in etc
f. Gaming
rduino no can e used to create simple ames or amin devices t
com ines pro rammin and electronics concepts in a fun and interactive ay
g. Audio projects
rduino no can also e used in creatin
audio related pro ects such as music
controllers sound installations or al in
piano
h. Testing product
Figure 3.51
n ineers and developers also use rduino
no to test electronic pro ects efore ma in comple hard are
Activity: 3.2
uild a smart dust in desi ned to automatically open its lid hen a user
approaches ith trash o uild the pro ect you need rduino s and other di erent
components collect all the components necessary hich are necessary to uild
the pro ect ou can ta e the help of your teacher to collect the components
76 Computer Science , Grade 9
Exercises
1. Write the full forms of the given abbreviations:
a c d e
2. Choose the best answer.
o ma e your pro ram enerate results you can use event loc called
a hen clic ed hen the sprite clic ed
(c) both (a) and (b) (d) none of the above
he ac round ima e in the sta e area is called
a ac round allpaper
c ac drop d desi n
hich type of loc in cratch is used to repeat actions
a otion loc ontrol loc
c oo s loc d ensin loc
hat is the primary use of sensin loc s in cratch
a o control sprite movements
o detect events li e ey presses or mouse clic s
c o display messa es on the sta e
d o add sound e ects to a pro ect
here are e tensions in cratch pro rammin
(a) 5 (b) 9 (c) 11 (d) 12
as hat s your name and ait is an e ample of loc
a sensin control c operator d loo s
Computer Science , Grade 9 77
hich loc in cratch for micro pro rammin is used to display te t or
patterns on the matri
a ho s loc isplay loc
c nimation loc d atri loc
hat are devices li e icro it and rduino used for
a hysical computin
om inin pro rammin ith physical devices
c reatin interactive pro ects
d ll of the a ove
3. Write short answers to these questions.
a hat is scratch
ist do n the components of cratch interface
c hat is a micro it ive any t o applications of micro it
d o does a micro it help in physical computin
e hat is me a
4. Write long answers to these questions.
a efine loc pro rammin alon ith its features
hat are the applications of loc pro rammin plain in rief
c o is loc pro rammin di erent from traditional te t ased
pro rammin
d hat are loc s in loc pro rammin escri e the loc components
of cratch pro rammin lan ua e
e hat is an rduino rite do n its types of components
f hat is a microcontroller hat is it used for
ou are iven a pro ram here the cat sprite rotates and says
amaste hen the sprite is clic ed ist and e plain the loc
components used in this pro ram
78 Computer Science , Grade 9
Lab Activities (Practical)
reate simple ames usin di erent loc s of cratch
a) MAZE game
ame description n this ame you control a sprite that moves throu h
a ma e to reach a oal ou have to avoid touchin the alls of the ma e
or you have to start over
ra or use a sprite from the li rary and dra a ac drop that loo s li e
a ma e usin the paint editor ou can also use the loo s loc to chan e
the color or ri htness of the ma e
se the motion loc s to ma e it move hen the arro eys are pressed
ou can also use the sensin loc s to eep the sprite inside the ma e and
to detect hen the sprite touches the alls or the oal
o ma e the ame more challen in you can use the control loc s to
add a timer and the varia le loc s to sho it on the sta e ou can also
use the sensin loc s to detect hen the timer runs out and the control
loc s to stop the ame ou can also use the sound loc s to play sounds
hen the sprite moves touches the alls or reaches the oal
2. Demonstrate online free coding simulation tools and its working
mechanism.
or icro it
a o to https ma ecode micro it or and select the icro it
ho the code editor here you can either rite codes or dra and drop
loc s
c ho icro it s physical parts li e pins etc in the simulator
d a e a asic pro ram usin loc s and run the simulator
e ho ho the pro ram ould or on a physical micro it
Computer Science , Grade 9 79
- For Arduino UNO,
a o to https tin ercad com circuits
ho the code editor and simulator
c ho rduino s physical parts li e read oard s resistors
etc in the simulator
d rite a asic rduino code li e tra c li hts and sho ho the
circuit or s
Project works
1. Develop an individual project using the Scratch tool.
a hin of di erent ideas for your pro ect t has to e a ame pro ect such
as ump ame appy ird sna e ame
a e sure you try to apply all the loc components that you have learnt
in the chapter
c ave your or from time to time so that you do not lose your or
d nce you complete your pro ect pu lish it online in your cratch account
f usin o ine do nload your or and share the filename s ith
your teacher
80 Computer Science , Grade 9
Unit 4 Web Technology
4.1 Concept of Web technology
Let’s think!
a hat is the e and hat does it mean to you
o can help students develop s ills
c hat features ould you add to a school or community e site
n today s di ital a e the internet has
ecome an inte ral part of our lives
providin us ith access to vast amounts
of information, communication, and
entertainment e sites are the uildin
loc s of the internet servin as platforms
for sharin information conductin
usiness and connectin people across
the lo e nderstandin e technolo y
is essential for anyone loo in to create
mana e or navi ate the online orld
e ectively Figure 4.1
he ord e is a out ho everythin is connected online information people
and devices nd hen e say technolo y e mean the tools computer pro rams
and lan ua es that ma e this connected e or and create our e periences on
the internet
e technolo y refers to the tools soft are protocols and lan ua es that
individuals usinesses and or ani ations use to create develop and mana e
applications and content on the nternet
t encompasses a road ran e of elements from fundamental uildin loc s li e
yperte t ar up an ua e for structurin content and ascadin
tyle heets for presentation and desi n to dynamic scriptin lan ua es such as
ava cript for interactivity erver side technolo ies li e ython and ode
s handle data processin hile e development frame or s li e eact n ular
Computer Science , Grade 9 81
and ue s provide structured approaches to uildin po erful applications
Figure 4.2
he landscape of e technolo y also includes considerations for e security
responsive desi n for various devices and adherence to e standards ensurin
a consistent and secure online e perience for the user verall e technolo y is
the ac one of our di ital interactions shapin the ay e access information
communicate and en a e ith the vast di ital ecosystem of the internet
Some examples of web technologies are:
a HTML: yperte t ar up an ua e the standard lan ua e for creatin e
pa es
CSS: ascadin tyle heets the lan ua e for stylin and formattin e
pa es
c JavaScript: scriptin lan ua e for addin functionality interactivity and
lo ic to e pa es
d PHP: server side scriptin lan ua e for creatin dynamic e pa es and
e applications
e Python: versatile pro rammin lan ua e commonly used for e
development oth on the server side and in frame or s li e an o
f MySQL: data ase mana ement system for storin and retrievin data for
e applications
WordPress: e content mana ement system for creatin and mana in
e sites and lo s
he future of e technolo y is li e an e citin ourney that ill chan e ho e
do thin s online t is full of creative ideas that ill ma e our di ital e periences
even etter
82 Computer Science , Grade 9
Let’s discuss!
iscuss the future of technolo y in the class hin a out the devices and ad ets
you use every day o do you thin they ll e chan ed and improved in the
comin years o ill these chan es a ect our lives et s share our thou hts
and ideas ith each other
4.2 Web Development Life Cycle
he e development life cycle is a systematic
process of creatin and maintainin a e site
t is a planned method that provides a fast
and easy development improvement and
maintenance of a e site hile ta in user
e perience functionality and adapta ility into
consideration hus it provides a roadmap for
e developers desi ners and sta eholders
to colla orate and deliver successful online
solutions Figure 4.3
a and achine earnin nte ration mart e sites are ein developed that
ill use and machine learnin to ive users personali ed content alon ith
su estions and do thin s automatically
a ro ressive e pps s ro ressive e apps are the e sites that
or li e an app directly in e ro sers hey or even hen you re o ine
and can send you notifications
u mented eality and irtual eality e sites usin and
features are ein developed uch e sites ill provide us ith e periences
that feel real and let us interact ith e content in e citin ays
c esponsiveness e sites ill eep ettin updated ma in them a lot more
responsive on di erent devices over time
d d e computin d e computin ill ena le computers to do their or close
to here the information is created hich ill ma e the performance of e
applications much faster and more e cient
e e security hortly e sites ill et smarter a out eepin our data and
information safe from online threats e technolo ies ill evolve to provide
Computer Science , Grade 9 83
advanced security measures such as stron er security codes etter ays to
chec ho you are and reach prevention
Did you know?
he first e site ent live on u ust
Stages of WDLC
Gathering information: n this sta e important information li e tar et
audience data content requirements and e site structure are athered
Planning: n this sta e a asic layout and desi n for the e site are created
descri in its eneral structure
Design and layout: his sta e involves selectin fonts colors and ima es to
ive the e site a loo that oes ell ith its content or rand
Content creation: n this sta e the actual content for the e site is created
usin te t ima es audio and videos
Development: n this sta e developers use code to convert the desi n and
content of e sites into a useful platform
Testing: t is the process of findin errors in the e site he e site
functionality is tested and errors are fi ed if found
Maintenance and updating: A website requires constant maintenance and
chan es to eep the content up to date and maintain smooth functionality
Let’s explore!
a e a roup in class and research the topic of e development life cycle
methodolo ies and hy they are important an you name some common
methodolo ies used in e development o do these methodolo ies di er in
their approach ive e amples of companies or pro ects that have successfully
implemented these methodolo ies ll researchers ive the presentation in class
and share their chosen methodolo y
DNS (Domain Name System)
n simple terms the omain ame ystem is a system that ives a unique
84 Computer Science , Grade 9
and suita le name to a e site he translates the name of a e site to the
nternet rotocol address that a computer can understand hen the name of
a e site is entered the computer sends a request to the server for the
address of the e site s server here are many types of omain ame ome of
them are listed elo
com ommercial
internet et or
np ountry ode op evel omain for epal
edu ducation
ov overnment
or r ani ation
Activity 4.1:
e have learned a out the di erent types of domains o e plore the e site
of the overnment side of epal our tas is to conduct research and ather
information a out various overnment sectors of epal ou can choose to focus
on areas li e education health transportation or any other sector that interests
you nce you ve athered the information fill out the elo ta le and discuss
it in the classroom
Department Name Link of the website Why is it important?
nland evenue https ta payerportal ird t helps in the payment of
epartment ov np ta payer app html ta to the overnment
DNS registration process
e site needs to o throu h the re istration process to have a lo ally
accessi le name omain ame erver translates identifia le names such as
domain names into numeric addresses e can re ister throu h many di erent
re istrars li e nestnepal com pra huhost com and ur hahost com he steps for
re istration of a domain name are iven elo
a Choose the domain name: Choose a domain name that is unique and
memora le that identifies your e site
Check the availability: erify the availa ility of the chosen domain usin the
re istrar s domain chec er tool
Computer Science , Grade 9 85
c Choose a domain name registrar: hoose a trusted re istrar to o cially
re ister your chosen domain name
d Buy and register your domain name: nce availa ility has een verified and
a re istrar has een chosen uy and re ister your domain name
e Do not lose your domain name: ene the domain re istration efore it
e pires so that you don t lose your domain name
Did you know?
e can freely re ister the np domain in epal https re ister com np
4.3 Concept of UI/UX
o understand the concept of e must understand the front end and ac
end hich are the foundations of every di ital creation
Figure: 4.4: - concept of UI/UX design.
Front End:
ma ine uildin a house the front end
is li e its slee e terior ut hat a out
the inner or in s hat s the ac
end hidden from vie yet essential for
functionality t s the comple net or of
irin plum in and structural support
that ensures the house stands stron ust
as the front end catches the eye the ac
end po ers everythin ehind the scenes
ma in the house or in the di ital orld Figure 4.5
86 Computer Science , Grade 9
the e site functional and liva le he part of a soft are application or e site that
users interact ith directly is no n as the front end he front end is hat you see
on your screen li e the uttons you clic the te t you read the ima es you vie
and the overall layout he front end helps in creatin a positive and en a in user
e perience he is also a part of the front end desi n
Back End
ac nd is the part of a soft are application or
e site that is responsi le for handlin operations
that are not directly visi le to users he ac end
does all the important tas s that eep the application
or e site runnin smoothly he ac end contains
data operatin synta functions and lo ic of the
application
Figure 4.6
Activities 4.2:
hin of it as a treasure hunt on the internet our o is to find out a out the tools
that help uild e sites irst loo for the tools that ma e e sites loo ood
li e colors and shapes hen find out hat tools are used to eep the e site
runnin on the server hen you find these tools fill out the ta le elo tell your
friends a out them and tal a out hy they are important
ools to ma e e site loo ood ools that help the e site eep runnin
UI (User Interface):
stands for ser nterface he point
of interaction between a user and a
di ital device or soft are application is
no n as a ser nterface t focuses on
a product s visual interactive elements
to create interfaces that are visually
appealin user friendly and easy to
navi ate
Figure 4.7
Computer Science , Grade 9 87
UX (User Experience):
stands for ser perience he overall e perience
of a user hen interactin ith a product service or
system is no n as ser perience t focuses
on understandin the user s needs ehaviors and
preferences to enhance user satisfaction
Advantages of UI/UX design Figure 4.8
a t increases user en a ement ith attractive desi ns
t enhances user e perience
c t helps in desi nin a unique loo for randin
d t helps in ma in e sites and apps easy to use and navi ate
e t saves development time and cost
n this ay the helps in desi nin the visual elements such as the uttons
colors and layouts you see hereas helps in ma in sure that usin the e site
is easy and en oya le and or to ether to transform the front end into an
interactive and user friendly e perience
Software used for UI/UX design
The following software can be used for UI/UX design:
a Figma: t is used for colla orative desi n here multiple people can or on
the same pro ect simultaneously
Adobe XD: t is used for creatin di erent interfaces uttons and layouts
c Balsamiq: t is a soft are used for creatin ireframes
Question
i hy is important in e technolo ies
ii ho ill create the desi n in e development
iii n hich sta e of desi n comes under
88 Computer Science , Grade 9
Let’s get more information!
ac in the s a clever computer scientist named Douglas Engelbart had a
vision e ima ined a ay for people to interact ith computers usin pictures
uttons and menus his idea ecame the foundation for hat e no call
desi n hin of it as creatin the loo and feel of soft are ust li e arran in
furniture in a room
Concept of wireframe
ireframe is an outline or a s eleton of a
sho in the asic structure and layout of a e
pa e or application ireframes are used in
the early sta e of the desi n process to outline
the placement of elements ithout ettin into
details of visual desi n or color e can use
di erent soft are such as etch i ma and
alsamiq to desi n ireframes Figure 4.9 Wireframe
Let’s check these questions!
a hy is ire frame important in e development
n hich sta e ireframe does come under
c ho ill create the ireframe in the soft are development
Concept of wireframe design
ireframe desi n is the process of creatin a simplified representation of a user
interface or e pa e ere are the ey aspects of ireframe desi n
Structural framework: he structural frame or refers to the asic layout
and or ani ation of a e pa e
User flow and navigation: user o is a visual representation of ho a user
navi ates and completes tas s ithin a di ital product hile navi ation refers
to the process of movin throu h and interactin ith a di ital interface
Quick interaction: ireframes are less detailed than the final desi ns o
they allo for quic repetition and chan es
Prototyping: rototypin is the process of creatin an openin model or sample
of a product system or application to test and confirm the desi n concepts
Computer Science , Grade 9 89
efore full development ireframes can e used to enerate interactive
prototypes
Cost-effective exploration: ireframe helps in findin pro lems early in
the desi n process to avoid costly mista es later on
Benefits of wireframe
a Easy to draw: ireframe has a simple and clean layout and consists of simple
screen elements
Easy to understand: ireframe is focused on the essential elements and
structure ithout any visual details or decoration
c Easy to modify: ou do not need to have an idea of any pro rammin lan ua e
to ma e chan es to a ireframe
d No coding required: ou can dra the ireframe as if you are usin a dra in
tool
4.4 HTML
Introduction to HTML
yperte t ar up an ua e is a lan ua e used to uild e pa es
yperte t is a te t hich contains lin s to other te ts and the term mar up refers
to the collection of sym ols or codes in a document that provides instructions on
ho the document should e formatted and processed hus a mar up lan ua e is
a ay to add notes comments or mar s to a document te t or other piece of data
to a e pa e
Let’s get more information!
or ynamic and or tensi le mar up lan ua e
are the other popular mar up lan ua es
here are many speciali ed soft are pac a es li e ream eaver frontpa e
co ee cup etc hich are used to create e documents
is a computer lan ua e that uses predefined ta s to define the structure
of e documents hich is the industry standard computer lan ua e for creatin
the s eleton of e pa es he mar up has no direct e ect on ho a computer
90 Computer Science , Grade 9
operates ut it does help to structure and present the content im erners ee
created in at the uropean article hysics a oratory in
eneva it erland he orld ide e onsortium is the or ani ation
that controls the development of ithout the orld ide e
ould not e ist
as developed y Tim Berners-Lee
in 1991 t as first released pu licly in 1993
and ecame the standard lan ua e for creatin
e pa es as pu lished in 1995,
hich included more features and remained
the standard until 19972 he development of
has een on oin ith ein
the latest ma or version
o create documents you can use a simple te t editor li e otepad or use
special soft are such as
Sublime Text: t is a feature rich te t editor that is oth versatile and fast
Visual Studio Code: t is a popular soft are that provides di erent tools to
create di erent soft are and e sites
Notepad++: otepad is a popular te t editor that can e used for creatin
documents
Figure 4.10.
HTML is commonly used for:
a reatin and desi nin the asic layout of a e pa e
reatin and formattin the te t content on e pa es
c m eddin the ima es raphics sounds videos on the e
d ddin ta les forms and hyperlin s on the e
Computer Science , Grade 9 91
Activity 4.3
s e already discussed a out the di erent types of te t editor tools let s et
ready to dive into the orld of e development y settin up otepad on
your computer no
HTML Tags
ach element on a e pa e is defined y an code or ta ta s tell
ro sers ho to display data ta s are predefined synta and commands
that perform specific tas s and are enclosed y an ular rac ets ta e ins ith
a less than si n and ends ith a reater than si n and information on the
screen and defines a e pa e s appearance layout and o ta consists of
three parts element identification of ta attri ute and value ta s are not
case sensitive hich means fonts ritten ithin the ta can e oth uppercase and
lo ercase ta s are of t o types
a. Container or Paired Tag
container or paired ta is a type of ta that has oth an openin and
a closin ta such as and he openin ta starts ith a less than
si n such as p ta and the closin ta starts ith a slash and a less than
si n such as p he openin ta activates the implementation of the ta
hile the closin ta stops it
b. Empty or Unpaired Tag
he ta hich does not have its correspondin closin ta is no n as an
mpty or npaired ta t has only the openin ta ut no closin ta t is used
to perform specific actions functions or tas s on the e pa e n empty ta
is also called a self closin ta or stand alone ta or e ample r inserts a
lan line and im ta inserts an ima e in a e pa e oth do not have a
closin ta
Activities 4.4
iscuss in the classroom and list do n some of the container or paired ta and
empty or unpaired ta
SN Paired tags Uses Unpaired tags Uses
1
92 Computer Science , Grade 9
HTML Attributes
n attri utes are special ords used in the openin ta s to control or modify
the ehavior of the ta s or e ample you can specify the si e color or
face y includin the appropriate attri ute ith the code
Figure 4.11 HTML Attribute.
Structure of HTML
very lan ua e has a certain
structure for proper and smooth
functionin i e ise
has its o n standard structure
hile creatin a e pa e
e nested inside elements
can other elements to uild a
hierarchical structure
Figure 4.11
he asic structure consists of four main parts the doctype declaration the
html elements the head element and the ody element
Lab task
ma ine you re creatin a e pa e to sho case my econd eacher in a i
and old ay an you rite some code to ma e it happen nce you re
done don t for et to run it to see your creation come to live on the screen
Creating HTML document in Sublime Text
o create an file all you need is a asic te t editor i erent operatin
systems have their o n te t editors SimpleText for ac Vim and Emacs
for inu and otepad for indo s operatin system dditionally there
are development tools li e dit e tpad ditplus and otepad
u lime te t ode etc files typically have e tensions li e .html or
.htm.
Computer Science , Grade 9 93
u lime e t is a pro ram for ritin and editin code on your computer u lime
e t has features li e synta hi hli htin hich colors di erent parts of your code
to ma e it easier to read autocomplete hich helps you complete your code faster
and customi ation options hich let you chan e ho the pro ram loo s and or s
ere are the steps to create and save an document in Sublime Text Editor
pen u lime e t ditor on your omputer
o do nload u lime e t ditor
o to https su limete t com do nload
o to the ile enu and clic on the ave option
u lime e t ill display save as a dialo ue o as in for a file name as
sho n in the fi ure elo
n the file name te t o type any name follo ed y html or htm e tension
and choose the drive location here you ant to save the file
lic the ave utton
o you are ready to rite code in u lime te t
Figure: 4.13
o vie your e pa e dou le clic on your file and you can see the output of the
document in your default ro ser
Organizing Text in HTML document
Comment Tag
he comment ta is used to insert a comment in the source code t is a
ay for developers to include notes or remar s ithin the code for various
purposes such as e planations reminders or temporary instructions
94 Computer Science , Grade 9
our omment ere
he comment ta requires an e clamation mar after the openin rac et
Example 1:
Figure: 4.14: - Example of Single-line comment
he <br> tag in is a special code that tells the e pa e to start a ne line
t is li e pressin the enter ey on your ey oard ou don t need to rite anythin
after the r ta ecause it is a self-closing tag
he e ro ser only identifies a sin le pace et een the ords or te ts even if
there are many spaces iven et een ords o add additional spaces et een the
te t you can use n sp sin sin le n sp is equal to one space dou le  
provides dou le space and so on
Paragraph Tag <P> t is used to create paragraphs in an html document
para raph is a roup of sentences a out a specific topic he p ta helps you
arran e your te t on a e pa e t puts the sentences that elon to ether in one
o hen you use the p ta you re sayin his is a para raph
ALIGN attri utes ith values “LEFT”, “CENTER” or “RIGHT” can be used to
set the ali nment of the para raph y default the ali nment of a para raph is left
Lab work!
s e already learned a out the structure of you are assi ned to rite
the structure comment on each line in the structure and su mit it to the
teacher fter the completion of the tas discuss in the class a out
a hy are comments important in odin
hat s the di erence et een sin le line and multi line comments
Computer Science , Grade 9 95
Text Formatting Tags
ta is a command in a e pa e that performs specific actions and tells the
ro ser to do fter e include the structure ta s e are ready to start placin
asic content in the document ody o or ith te t appearin in a e ro ser
e use te t formattin ta s e t formattin ta s are special purpose ta s that are
used to chan e define or enhance the visual appearance and style of content on a
e pa e sin te t formattin ta s e can ma e our e te t content old italic etc
Heading Tags (<H1> …. <H6>) hese ta s are used to provide headin s in an
document supports si di erent levels of headin s he i est
header format is and the smallest is ll the styles of headin s ta s
appear in BOLDFACE and the si e of the headin depends on the level chosen
ie to
HTML Input Output:
h his is headin one h his is headin one
h his is headin t o h his is headin t o
h his is headin three h his is headin three
h his is headin four h his is headin four
h his is headin five h his is headin five
h his is headin si h his is headin si
ori ontal ines t is used to dra hori ontal lines or rulers to separate
contents in an pa e t dra s a line across the pa e from left to ri ht and is
a self closin ta he attri utes of the ta is
Attributes Description
t is used to ali n the line on the ro ser
screen ali ned to the center y default
ALIGN=LEFT ill ali n the line to
the left of the screen
ALIGN=RIGHT ill ali n the line to
the ri ht of the screen
ALIGN=CENTER ill ali n the line
to the center of the screen
96 Computer Science , Grade 9
t is used to chan e the si e of the line
t is used to set the idth of the line t
can e set to a fi ed num er of pi els
or a percenta e of the availa le screen
idth
t is used to chan e the color of the line
HTML Input
color lue
epal is the irthplace of ord uddha
Text styles
ou can use these ta s to chan e ho your te t loo s ma es it old
ma es it italic ma es it underline he
and ta s are used for superscript and su script respectively or
e ample and mc
HTML Input
his te t is old
i his te t is italici ed i
u his te t is underlined u
sup sup sup sup
su su
Output:
his te t is old
his te t is italici ed
his te t is underlined
A2 2
H2O
a ontrollin ont i e olor and ace
Computer Science , Grade 9 97
ll te t specified ithin the ta s and ill appear in the font
face si e and color as specified in the attri utes of the ta he attri utes
are
FACE ets the font to the specified font name
SIZE ets the si e of the te t he default si e of the font is
COLOR ets the color of the te t olors can e set y their name or usin
he adecimal codes
HTML Input
face imes e oman i e color ed alent is not hat
you have talent is hat you do
ou can use color codes to choose the color of your te t or ac round on your e
pa e color codes are special codes that have si num ers or letters he
color codes tell the computer ho much red reen and lue should e in a color
Here are some of the basic color codes:
lac #000000 White #FFFFFF
ed #FF0000 reen #00CC00
lue #0000FF ello #FFFFF00
ilver #C0C0C0 Lime #00FF00
ray #808080 Maroon #800000
urple #800080 Aqua #00FFFF
HTML Input
ont color aroon ont
ont color ray ont
ont color reen ont
The Marquee Tag:
he marquee ta in ma es your te t ima e raphics and videos move
or scroll on your e pa e
98 Computer Science , Grade 9
Attribute escription alues
ehavior crollin ehavior lternate slide scroll
irection crollin direction eft ri ht up do n
color ac round color olor name or value
scrolldelay elay in scrollin num er in millisecond
ei ht ei ht of scroll area num er in pi els
width idth of scroll area num er in pi els
HTML Input
ill e a e developer
marquee ehavior scroll direction do n color
scrolldelay am arquee unnin e t marquee
Let’s have Quiz!
Which tag is used to create a scrolling text or image in HTML?
a scroll
animate
c marquee
d slide
Which attribute in HTML is used to horizontally align text or images within
an element?
a li n
enter
c ori ontal ali n
d e t ali n
Activity:4.5
a e a marquee to display the future of learnin my econd eacher
Computer Science , Grade 9 99
4.4.5 Anchor, List, Table, Image Tags and Their Properties
1. Anchor Tag
he anchor ta is an element used to create hyperlin s on e pa es
yperlin s are used to direct users to di erent sections of the same e pa e
another e pa e or various types of data such as files ima es or documents
he anchor ta is denoted y the a element
The browser distinguishes hyperlinks from the normal text. Hyperlink
has the following features:
a y default hyperlin ed te ts appear lue in color
he hyperlin te t ima es are underlined
c hen the mouse pointer hovers over the hyperlin te t it chan es into the
shape of the pointin hand
Syntax: < a href = “ URL/ path of page or document”> text displayed on
page </a>
Attributes of anchor tag:
href: t specifies the of the pa e or document the lin navi ates or umps to
target pecifies here to open the lin ed pa e or document he values of the
tar et attri ute is
_blank: pens the lin ed document in a ne ro ser indo or ta
_ parent: pens the lin ed document in the parent frame or indo
_ self: pens the lin ed document in the same frame or indo
pens the lin ed document in the full ody of the indo
_ top:
rea in out of any frames
Hyperlinks can be of two types:
a External link: t lin s to an e ternal e document of the same or di erent
e site
nternal lin t lin s to the specific location of the same e pa e
100 Computer Science , Grade 9
External Document References
Example 2:
in hec isit my ome a e
HTML INPUT
sin ternal in s
y lue
isit the follo in lin s to e plore epal
http nt ov np epal ourism oard e site
http e plorenepal com plore epal
http mofa ov np inistry of orei n airs e site
Intra-page links or bookmarks
ntra pa e lin s or oo mar s are used to direct the user to a di erent location on
the same pa e t is also possi le to ump to a particular location on another e
pa e usin oo mar s
Using Name Anchor
o use intra pa e lin s a name anchor is used or instance top
ere it is necessary to ive a name at the specific point on the pa e here
the ta occurs he ta must e included ut no te t is required et een
and
he sym ol identifies the ord as a named anchor point ithin the current
document rather than a separate pa e hen a reader clic s on the e
Computer Science , Grade 9 101
ro ser ill display the part of the pa e startin ith the top ta
Example 3:
nput
html
nternal in ample
nav
nternal lin s in the navi ation menu
section ection
section ection
nav
ontent for ection
id section ection
his is the content of ection
in ac to the top of the pa e
top ac to op
ontent for ection
id section ection h
his is the content of ection
in ac to the top of the pa e
top ac to op
102 Computer Science , Grade 9
Email link
ou can use the ta to ma e lin s that open an email hen you clic on an
email lin it starts a ne messa e addressed to the set email he email address
should e ritten after mailto in the ta
Example 4:
nput
end your email to mailto info moecdc ov np urriculum
evelopment enter anothimi ha tapur
2. HTML Lists
list in is a ay of roupin related items in an ordered or unordered
form here are three types of lists unordered (with bullet points), ordered
(with numbers), and description lists ach item in the list is mar ed ith
a specific ta li e li for unordered and ordered lists or dt and dd for
description lists
Unordered List <UL> (Bullets)
n nordered list starts ith the ta and ends ith ach list of
items starts ith the ta he attri utes that can e specified ith
are
Computer Science , Grade 9 103
TYPE pecifies the type of ullet
TYPE provides a solid round lac ullet
TYPE provides a solid square lac ed ullet
TYPE provides a circle ullet
Example 5: HTML Input
ome of the eavenly laces of epal
urma arovar
alital
amaroshan
Output:
ome of the eavenly laces of epal
urma arovar
alital
amaroshan
Ordered Lists <OL> (Numbering)
n ordered list starts ith the ta and ends ith each list item starts
ith the ta he attri utes that can e specified ith are
TYPE ontrols the num erin scheme to e used
provides a list in countin num ers
provides a list ith letters
a provides a list ith lo ercase letters a
provides a list ith oman um ers
i provides a list ith lo ercase oman um ers i ii iii
104 Computer Science , Grade 9
START lters the num erin sequence list can e started ith any numeric value
VALUES han es the num erin sequence in the middle of an ordered list
Example 6: HTML Input
ome of the eavenly laces of epal
urma arovar
alital
amaroshan
Output:
ome of the eavenly laces of epal
urma arovar
alital
amaroshan
Definition Lists
efinition list values appear ithin ta s and t consists of t o parts
efinition term ppears after the ta
efinition description ppears after the ta
Example 7: HTML Input
ront nd
here user interacts ith the system
ac nd
here the lo ic of the system is ritten
Computer Science , Grade 9 105
Output:
ront nd
Where user interacts with the system
ac nd
here the lo ic of the system is ritten
s per the requirement e can also use ested ist a list inside another list
3. Adding Images to HTML Document
n esides te t e can add still or movin pictures to a e pa e
he common picture formats are dot if and dot p oft are such as
if onstructor or do e hotoshop can e used to create and save ima es
in these formats o put an ima e on a e pa e e use the im ta and
set the attri ute to the ima e file name e filename if or filename
p
ynta ath of ma e ource of ma e
he im ta in is used to em ed ima es or pictures into a e pa e
ta ta es the follo in attri utes
Attributes Value
SRC ath or location and name of the ima e file
ALIGN efines the position of the ima e left centre ri ht
BORDER efines the si e of order of the inserted ima e
WIDTH efines the idth of an ima e in pi el value or percenta e of
the ro ser s indo
HEIGHT efines the hei ht of an ima e in pi el value or percenta e of
the ro ser s indo
HSPACE efines a space of specified si e to the left and the ri ht of the
ima e
VSPACE efines a space of specified si e to the top and the utton of
the ima e
ALT efines the alternate te t ased information if the user is una le
to vie the ima e due to server or net or in issues
106 Computer Science , Grade 9
Example 8: HTML Input
ducation in ation uildin
yello alternate
ri ht ducation nli htens the tudents
color lue
center nsertin ima e in ocument
ima es my ma e p
omputer ducation
ima es my ma e p
Note: hile savin ima es you can ive the full path or save the ima e file in your
document s location
4. HTML Tables
a le is the com ination of ROWs and COLUMNs a les are commonly used
o ects to define the layout of a e pa e ta le in starts ith
ta and closes ith ta ach headin ro of a ta le is defined et een
<TH> </TH> ta s ach ro of a ta le is defined et een the <TR> and </TR>
ta s i e ise each column data of a ta le is defined et een the <TD> and
</TD> ta
unday Monday uesday Wednesday
5 7 10 21
11 13 3 4
Computer Science , Grade 9 107
Header Row:
ach ta le has a ta le header t is defined usin ta he content of
the ta le header ro is automatically centred and appears in oldface
ata cells hold data to e displayed in the ta le data ro is defined usin
ta s he te t matter displayed in a data ro is left ustified y default
ny special formattin li e oldface or italics is done y includin appropriate
formattin ta s inside the ta s n ima e can also e displayed in a
data cell
The attributes that can be included in the <TABLE> tag are:
Attributes Description
BORDER t defines the order and its thic ness of ta le he order
thic ness is specified in pi els efault si e of the order is
Example: <TABLE BORDER = 3 >
BGCOLOR t defines the ac round color of the ta le
Example: <TABLE BGCOLOR = pink >
HEIGHT t defines the hei ht of the ta le alue for hei ht attri ute
can e defined either in pi el a solute or in percenta e
relative f ei ht is not specified the data cell is ad usted
ased on the cell data value
Example: <TABLE HEIGHT = 350 >
WIDTH t defines the idth of the ta le alue for idth attri ute
can e defined either in pi el a solute or in percenta e
relative f idth is not specified the data cell is ad usted
ased on the cell data value
Example: <TABLE HEIGHT = 200 >
ALIGN t defines the hori ontal ali nment of the ta le he value of
li n attri ute can set to
Example: <TABLE ALIGN = LEFT>
108 Computer Science , Grade 9
CELLPADDING t defines the space et een content ithin the cell and
order of the cells
Example: <TABLE CELLPADDING = 5 >
CELLSPACING t defines the space et een the cells of the ta le
Example: <TABLE CELLSPACING = 3 >
COLSPAN t lets a ta le cell occupy or stretch over multiple columns
hori ontally t is applied to the td or th elements inside
a ta le
ROWSPAN t lets a ta le cell occupy or stretch over multiple ro s
vertically t is applied to the td or th elements inside
a ta le
BACKGROUND t defines the ac round ima e of the ta le
Example: <TABLE BACKGROUND = “[Link]”>
Caption Tag
caption for a ta le in is defined usin the caption ta he caption
is usually sho n on top of the ta le and ives a short title or summary of hat the
ta le contains he caption ta is inserted ri ht after the openin ta le ta he
ta le caption can e made to appear a ove or elo the ta le structure ith the help
of the attri ute as iven elo
ALIGN t controls the placin of the caption ith respect to the ta le
Example: ALIGN = BOTTOM ill place the caption immediately
elo the ta le
ALIGN = TOP ill place the caption immediately a ove the ta le
VALIGN and ALIGN
he VALIGN attribute controls ho the content is ali ned vertically inside a ta le
cell t can e used on sin le cells td or th ro s tr or the hole ta le
he VALIGN attri ute can have these values
top he content is placed at the top of the cell
middle he content is centred vertically in the cell
bottom he content is placed at the ottom of the cell
Computer Science , Grade 9 109
Example 9: VALIGN
top op ali ned content
middle iddle ali n content
ottom ottom ali n content
he ALIGN attribute controls ho the content is ali ned hori ontally inside a
ta le cell t can e used on sin le cells ro s or the hole ta le
The ALIGN attribute can have these values:
left he content is placed at the left ed e of the cell
center he content is centered hori ontally in the cell
right he content is placed at the ri ht ed e of the cell
Example 10: ALIGN
left eft ali ned content
center enter ali ned content
ri ht i ht ali ned content
Example 11: Sample table in HTML
110 Computer Science , Grade 9
ashupatinath emple
indu emple in athmandu
ncient rchitecture
oudhanath tupa
enter for uddhism
eli ious ituals
Figure: 4.15
Example 12: Using the CELLSPACING attribute in HTML
Computer Science , Grade 9 111
<CENTER> <H3> TABLE WITHOUT CELLSPACING </H3> </CENTER>
ithout ellspacin
rishna
hiva
am
<CENTER> <H3> TABLE WITH CELLSPACING </H3> </CENTER>
ith ellspacin
112 Computer Science , Grade 9
rishna
iva
am
Example 13: Using ROWSPAN and COLSPAN
Computer Science , Grade 9 113
ROWSPAN = “2”
COLSPAN = “3”
idhya
i ash
114 Computer Science , Grade 9
Form and Div Tag
1. HTML <FORM> tag
ou have pro a ly seen and filled out di erent forms on e sites li e login
form, contact form, registration form, search form and so on he main
purpose of these web-based forms is to get data and information from the
end users and send them to a server for processin
forms are a client side o ect that provide an interface et een client
and server ta is used to create a form in documents orm
ta can contain various input elements alon ith other contents his
is hy the form element is also no n as a container for di erent types of
input element
he input element or ta in is a e i le form ta that can ma e
di erent inds of input fields inside a form ta he type attri ute ith input
element decides the type of input field that includes te t o es chec o es
radio uttons su mit uttons and more
he openin ta of the ta includes the attri utes name method and
action ame is used for definin the name of the form he ethod attri ute
can e either or hich determines ho the form data is ein sent
to the server he ction attri ute is a pointer to the script that processes the
form on the server side
Activity 4.6:
esearch on the internet and collect t o or more forms and try to fill out the form
t is etter if student find the ov sites form
Form elements in HTML
a. Text Fields
e t fields ena le end users clients to type te t into a sin le line input field
te t field is an input field here users can type te t or alphanumeric characters
o create a te t field you can either use in the
element or leave o the specification alto ether he default for
the ta is te t
Computer Science , Grade 9 115
Example: ser ame
TYPE etermines hat type of data is allo ed for input
NAME etermines the name of the field that passes to the script processin
the form
SIZE ndicates the len th of the te t entry field in characters he default
field si e is characters
Example 14: Using “text” INPUT type
la el sername la el
nput type te t ame ser ame
la el ass ord la el
nput type pass ord ame ser ass
utput
Note:
< input type = “ Password “> lets users type in sensitive information li e
pass ords securely he actual characters they type are not sho n
Lab work!
e can add activities here li e input username a e phone num er and other
b. Text Area
he te tarea ta in creates a multiline te t input field in a form sers
can type and send multiple lines of te t ith it so it is ood for lon er te ts
or free form content or e ample if you ant to create a form that ena les
readers to compose electronic mail you mi ht use a te t area for the ody of
the messa e
116 Computer Science , Grade 9
Syntax: e tarea ame ody rea o s ols
nter your messa e ere e tarea
<TextArea> Attributes
NAME he name to e sent hen the form is su mitted
ROWS he hei ht of the te t area element num er of ro s
COLS he idth of the te t area element in the column num er of columns
Lab work!
a e a te t area for the messa e for the a ove form
Example 15: Using “Textarea ” INPUT type
omments r
te tarea ro s cols name details
rite your comment here
te tarea
Output:
c. Radio Button
radio utton in an form is an input element that lets users pic only
one option from a roup of options that cannot e pic ed to ether f one radio
utton in a list is selected all the rest of the radio uttons in the same list et
deselected
Computer Science , Grade 9 117
Example 15: Using “Radio” INPUT type
adio ame result alue ass
adio ame result alue ail ail
Output:
Activities: 4.7
dd the radio utton for the a e i e ale emale and others in the form
d. CheckBox
nli e adio utton chec o allo s us to choose multiple items at a time in
a hec o list ach chec o can e either chec ed or unchec ed
Example 16: Using “Checkbox” INPUT type
h ist of a es in epal h
nput type hec o ame hey ho sundo a e hey ho sundo
a e r
nput type hec o ame ara a e ara a e r
nput type hec o ame oisai unda a e oshai unda a e r
Output:
Activity:4.8
e can add the ho ies in the form such as pro rammin lan ua e uitar
foot all and others in the a ove form
118 Computer Science , Grade 9
e. Select Box
t is used to create pull do n menus and scrollin lists he select ta in
creates a dropdo n list or a select o in a form sers can pic one
or more options from a list of options that are already set he option ta s
inside the select ta ma e the options for the dropdo n list or select o
elements or li e radio uttons or chec o es ut the interface
is di erent
Example 17: Using “select ” INPUT type
or in ith elect o
ody
form
p elect a istrict p
ame istrict
option value u u option
ption value anan anan ption
ption value anchthar anchthar ption
ption value iraha iraha ption
ption value apilvastu apilvastu ption
form
ody
Output:
Computer Science , Grade 9 119
Activity:4.9
a e the address in the form and ma e the select o in the form
f. Buttons
he utton ta in creates a utton that can e clic ed on a form or
any here on a e pa e he utton can have te t ima es or other
ta s inside it t is used to perform specific tas s or perform events hen it is
clic ed here are t o types of uttons
i Submit Button: t tells the ro sers to send the form data to the server
ou should include at least one su mit utton on every form
Syntax: input type su mit value su mit
Note: alue attri ute is used to ive the te t display in a utton
ii eset utton t is used for resettin the elements of a form t allo s the
user to fill ne entries all over a ain
Syntax: input type reset value reset
Example 18: Using “select” INPUT type
form
input type su mit name su mit value u mit
input type reset name reset value eset
form
utput
dd the su mit and reset utton on the form at last
120 Computer Science , Grade 9
Lab work!
Let’s make a form like below.
2. HTML <DIV> Tag
Context:
he div division ta in is a division or container element that is used to
divide a e document lo ically t helps to organize and arrange content on a
webpage t is a loc level container that can contain other elements
he div ta can e styled ith to chan e its appearance si e position and
layout t can also have an id or a class attri ute to identify it or roup it ith other
elements
Advantages of using DIV tag
a roupin ontent ayout and tructure
c esponsive esi n d tylin ith
e ava cript nteraction
Computer Science , Grade 9 121
Example 21: Sample Layout using <DIV> Tag
html
html
head
title ample title
head
ody
<! - - Parent DIV - ->
div style order p solid mar in p paddin p
h ain h
<!-- First Div -->
div style order p solid mar in p paddin p
p irst iv p
ontent of the first div oes here
div
<!-- Second Div -->
div style order p solid mar in p paddin p
p econd iv p
ontent of the second div oes here
<!-- Third Div inside Second Div -->
div style order p solid mar in p paddin p
p hird iv p
ontent of the third div oes here
div
div
div
ody
html
122 Computer Science , Grade 9
iv efines a division or a section in an document
o tyle a specific element directly you can use the style attri ute ith
inline
Let’s know
a hy is div needed hile ritin code ith its advanta es
rite a code usin the div function to print he hei ht of
a armatha is m
4.5. Cascading Style Sheets (CSS)
Dynamic Hypertext Markup Language
stands for Dynamic Hypertext Markup Language t is a technolo y
that allo s e developers to create interactive and animated e sites
uses to define the structure of a e pa e such as ta les frames para raphs
lists and so on t also uses CSS to control the appearance and layout of the
HTML elements such as colors fonts mar ins and positions n addition it uses
scriptin lan ua es such as ava cript and cript to access and modify the
elements and styles dynamically ased on user actions or events
Cascading Style Sheet
Context:
is a lan ua e that uses ta s to create di erent elements on a e pa e such
as te t lin s ima es and videos is another lan ua e that or s ith
to style and layout these elements ou can use to chan e the color font and
si e of a para raph element or e ample
< p style = “ color : #ff0000; font-weight: bold “> CSS helps to define Style </p>
is a lan ua e that or s ith to style and format e pa es t can
change the appearance of elements such as colors layout and fonts t can also
help to define responsiveness hich means ad usts the presentation to suit
di erent devices such as des tops mo iles or printers
s said in the definition can e defined in such a ay that it can change
layout, colors, fonts or any other styles based on the size of the screen (PC
Computer Science , Grade 9 123
creen a let screen and mo ile screen or for printers n a des top computer
screen si e is lar e hereas in mo ile screen si e is small and accordin ly
content should e presented to e pa e vie ers is used to define this type of
presentation lso if a vie er is tryin to print a e pa e the presentation of the
pa e can e made di erent usin to ma e it printer friendly
he Style assignment is done with <STYLE>…</STYLE> ta s et een
the ta s specific style attri utes are listed he tyle ta s are ritten ithin the
ta s
CSS Syntax:
ype te t css
a attri ute value attri ute value
Attribute: ont olor ac round e t order ar in and ist
Let’s answer these questions!
hy is important in e development
hat are the advanta es of
A CSS rule is formed from:
´ set of properties hich have values set to update ho the content
is displayed or e ample ant my element s te t color to e hite and its
ac round to e rey
´ selector hich selects the element s you ant to apply the updated property
values to or e ample ant to apply my rule to all the para raphs in
my document
´ set of rules contained ithin a stylesheet determines ho a e pa e
should loo
124 Computer Science , Grade 9
et s ma e thin s clear ith an e ample irst of all let s ta e a simple
document containin an h and a p
Example 1:
html
html
head
title y irst ample title
style
h
color lue
ac round color yello
order p solid lac
p
color red
style
head
ody
h ello orld h
p his is my first e ample p
ody
html
4.5.1. Properties of CSS
is a lan ua e that or s ith to style and format e pa es t has t o
main components
Properties: hese are the names of the aspects of the e pa e that you ant to
modify such as font idth ac round color etc
Computer Science , Grade 9 125
Values: hese are the specific settin s that you assi n to each property such as
rial lue etc
property and a value to ether form a declaration ou can roup multiple
declarations inside a eclaration loc ou can also use selectors to
specify hich elements the eclaration loc applies to his creates
a ule et or ule ach property has a predefined set of values that are
valid for it
4.5.2. Selectors
selectors are e pressions that identify tar et and select elements on
a e pa e and apply styles to them electors are part of hich ena le you
to chan e the appearance of elements ithout chan in the code electors
are essential for creatin the rules that control the style and layout of a e pa e
Types of CSS Selectors:
1. Element selector
t is used to select elements ased on the element name
Example:
tyles applied to all elements
2. ID Selector
t is used to tar et a specific element ased on its unique attri ute
s each element s must e unique ithin a pa e the selector allo s the
126 Computer Science , Grade 9
selection of a sin le distinct element o select an element ith a specific id
rite a hash character follo ed y the id of the element
Example:
header
tyles applied to the p element ith id header
ody
p id header am d elector ith d name chec p
ody
3. Class Selector
he class selector is used to select and style elements that have a
certain class attri ute o select elements ith a certain class a dot is ritten
follo ed y the class name
Example:
chec
tyles applied to all elements ith class chec
ody
p class chec am lass elector ith class name chec p
ody
4. Universal Selector
he universal selector in is a sym ol that is used to select all
elements on a e pa e t matches any element type allo in you to apply
styles to every element ithout specifyin individual element names classes
or s
Computer Science , Grade 9 127
Example:
tyles applied to all elements
property value
dditional styles
4.5.3. Types of CSS:
here are three di erent ays to apply to an document
nline nternal and ternal
i. Inline CSS
t is a ay of stylin elements directly into an document ou
can do this y addin the style attri ute to the ta s nline lets you
set specific styles for a certain element ithout chan in other elements on the
pa e
Example:
html
html
head
title y periment title
head
ody
h style color lue ac round color yello order p solid lac
ood ornin lass h
p style color red his is my first e ample of nline styles p
ody
html
128 Computer Science , Grade 9
ii. Internal CSS
nternal is a method of stylin elements ithin the document
itself nstead of stylin each element individually internal allo s you to
define styles for multiple elements ithin a sin le style ta in the head
section of the document
y addin code inside the openin head and closin head ta inside
an file e can or ith num ers of elements at a time in
order to define styles on the same e pa e
Example:
html
html
head
meta charset utf
title y irst ry a e title
style
h
color lue
ac round color yello
order p solid lac
p
color red
style
head
ody
h ello orld h
p his is my first e ample of an nternal stylesheet p
ody
html
Computer Science , Grade 9 129
iii. External CSS
ternal is a method of stylin elements y placin the code
in a separate e ternal file ith a css e tension his file is then lin ed to the
document usin the lin ta in the head section
nli e inline or internal e ternal allo s for the separation
of style and content ma in it easier to mana e and maintain styles across
multiple e pa es his approach promotes code reusa ility as the same
file can e lin ed to multiple documents ensurin consistent stylin
throu hout the e site
Example:
html
html
head
meta charset utf
title y periment ith ternal tylesheet title
lin rel stylesheet href mystyle css
head
ody
h isit epal h
p a armatha also no n as t verest is the hi hest mountain on arth
and a
sym ol of oth natural eauty and human determination ere are some ey
details a out a armatha ount verest p
ody
html
130 Computer Science , Grade 9
And (create a new file) code for [Link] file:
h
color lue
ac round color old
order p solid lac
p
font si e pt font ei ht old te t ali n ustify color red
i. Common CSS properties reference
Property Values Used with Elements
color ed reen any element that contains
lue he values te t
text-align left ri ht centre ustify loc elements li e h
h p li etc
text-decoration none underline overline mostly ith a anchor
line throu h lin inherit elements
text- none capitali e uppercase any element that contains
transformation lo ercase te t
line-height or p loc elements h h p
li etc
Computer Science , Grade 9 131
letter-spacing normal or p value any element that contains
te t
font-family font or font family font or any element that contains
font family te t
font-size p or em value any element that contains
te t
font-style normal italic o lique any element that contains
te t
font-weight normal old any element that contains
te t
background- ed reen any element ith a
color lue he values ac round
background- url ima e url mostly ith ody
image
background- repeat repeat repeat y mostly ith ody
repeat no-repeat
background- left center ri ht top mostly ith ody
position center ottom
list-style-type disc square circle ul
list-style-type decimal lo er roman ol
upper roman lo er alpha
upper alpha
ii. CSS Box Model
is a lan ua e that ma es e pa es loo nice t uses the o model to arran e
elements on the pa e ach element is li e a o ith four parts
here are several properties in that are often rouped to ether as box properties
hich control the ay ro sers layout the pa e usin the box model
or e ample if e have an element li e a <h2> Element Contents </h2>) on the
pa e here are the parts of its o hen dra n
Content: t is hat you see inside the o such as ords pictures or videos
132 Computer Science , Grade 9
Padding: t is the cushion around the content t ma es the o i er and more
comforta le
Border: t is the frame around the content and paddin t sho s here the o
ends and the ne t one e ins
Margin: t is the ap et een the o es t ives some reathin room and eeps
the o es from touchin
CSS code:
h
paddin em
order medium dashed lac
ac round color rey
t ill ma e the <h2> have a ray ac round ith 1 em of space et een the te t
and the order he space inside the order even if it is invisi le ecause e do not
have one is covered ith the ac round color and is controlled y the padding
properties
f e ant more space separatin this element and its order from the stu around
it e ould have to increase the margin values t s easy to mista e mar in for
paddin especially hen there is no order or ac round color f you are tryin
to chan e the space around an element especially hen the ro ser s default
has some space there try settin oth mar in and paddin to ero and or from
there
Computer Science , Grade 9 133
ul
mar in em
paddin em
iii. CSS measurement units
ere are some common units of measurement used in
em - he current font si e nother unit an e is half the te t si e
px - ne screen pi el dot on the display ote for some very hi h resolution
devices real pi els are very small so this len th is ad usted to e close to the
si e of a pi el on a traditional display
mm - millimeter here are also units for centimeters inches etc ote
his is the ro ser s est uess ut mi ht e inaccurate dependin on the
scalin of the display pro ector phone etc or e ample if you display your
screen on a pro ector the millimeter suddenly ecomes much lar er
s much as possi le it is etter to specify measurements usin ems and p s
hese are the only units that do not require any ind of note
p
line hei ht em
loc quote
mar in left em
order left em solid lac
lo oim
idth p
hei ht p
oat left
mar in left em
ere is an e ample pa e that e can style ith some of the properties a ove
134 Computer Science , Grade 9
Example 5:
html
html
head
meta charset
title roperties title
lin rel stylesheet href css prop css
head
ody
h roperties h
h oals h
p his is a pa e that e re usin to demonstrate various properties and
techniques ecause of that it is pro a ly oin to e u ly p
h esults h
p es it is turnin out rather u ly ut it is important to demonstrate some
stu ere are some of the ne thin s p
ul
li more properties li
li the o model li
li the units of len th used li
ul
ody
html
Computer Science , Grade 9 135
CSS to go with it:
ody
font family elvetica sans serif
h
te t ali n center
font ei ht old
ac round color silver
color teal
paddin em
h
order medium dotted teal
font ei ht normal
paddin em
ry e perimentin ith on this pa e or one you have created
DID YOU KNOW?
hort hand properties in allo you to set multiple related properties usin
a sin le declaration or e ample instead of ritin separate lines of code for
font si e font family and font ei ht you can use the font property to set them
all at once
136 Computer Science , Grade 9
Exercises
1. Write down the full forms of:
a c e i
d f h
2. Choose the correct option.
a hat does stand for
i yperlin s and e t ar up an ua e
ii yperte t ar up an ua e
iii ome ool ar up an ua e
iv yperpa e ar up an ua e
hich of the follo in is a commonly used te t editor for e development
i icrosoft ord ii otepad
iii u lime e t iv hotoshop
c hoose the correct ta for the lar est headin
i h ii h
iii i headin iv h
d hat is the correct ta for insertin a hori ontal line
i r ii hr iii ar iv tr
e hat is the correct for addin a ac round color
i ody color yello
ii ac round yello ac round
iii ody color yello
iv ody ac round yello
f hoose the correct ta to ive ase value
i o er ii sup iii ase iv su
hoose the correct ta to create a hyperlin
i a ii iii c iv d
Computer Science , Grade 9 137
h hat is the correct for ma in a hyperlin
i a url http nt ov np epal ourism oard a
ii a href http nt ov np epal ourism oard a
iii a name http nt ov np epal ourism oard a
iv a http nt ov np a
i o can you ma e an email lin
i mail yyy mail ii a href mailto yyy
iii mail href yyy iv a href yyy
o can you open a lin in the same ro ser indo
i a href url tar et lan
ii a href url tar et ne
iii a href url same
iv a href url tar et self
hich sym ol is used to denote an selector in
a c d
l hat is the primary purpose of a ireframe in e development
i o test functionality ii o sho case final desi n
iii o outline asic structure and layout
iv o implement codin
m n e desi n hat does primarily focus on
i ser nteraction ii ser ploration
iv ser pression v ser perience
n here are types of
i one iii t o ii three iv four
o hich of the follo in ta s is used for creatin ternal tyle heets
i style src mystyle css
ii stylesheet mystyle css stylesheet
iii lin rel stylesheet href stylesheet file name
iv lin rel stylesheet html href url
138 Computer Science , Grade 9
3. Write short answers to these questions.
a hat is
efine ta
c hat is the main function of ta
d hat is an attri ute
e hich ta is used for rea in lines or para raphs in
f hat is an mpty ta
hat is a container ta
h rite do n the synta of the comment ta
i hat is the output of a sup sup ta
hat is the function of ta
rite do n the use of orm in e pa es
4. Write long answers to these questions.
a hat is ist out any three uses of
rite do n the structure of
c plain e evelopment ife ycle
d ist out the importance of
e o is the ta used ist out the attri utes of the ta ith
its attri utes
f hat are the di erent types of nput types in
hat is the ta rite do n the importance of the ta
h hat is ist out its advanta es
i plains the types of
hat are selectors hy is it important
Project work
Develop a Static Web Page Using HTML and CSS.
his pro ect ill help you learn the asics of e development hich is a valua le
s ill in today s di ital orld ou ill learn ho to use and to create a
Computer Science , Grade 9 139
e site that sho cases your personal portfolio ou ill also learn ho to desi n a
e site that is user friendly responsive and attractive
Website Overview
n this pro ect you ill create a e site for yourself t ill have four pa es ome
allery ontact and nformation ach pa e has a di erent o he ome pa e
elcomes visitors the allery sho s your personal portfolio ima es the ontact
pa e lets people reach out to you and the nformation pa e shares important details
a out you his pro ect is a chance for you to e creative and sho o your s ills
hile helpin yourself shine online
our tas is to desi n and develop a static e site for yourself
he e site should consist of four main pa es ome allery ontact and
nformation
ach pa e should have a consistent navi ation ar nav ar and footer desi n
tili e for structurin the content and for stylin and layout
WireFrame
Design Wireframe of your Webpage.
Navbar
nav ar is a part of a e site that helps you find other pa es on the site t usually
has the site name and some uttons at the top ou can clic on the uttons to o to
di erent pa es
Perform:
reate a nav ar that is consistent across all pa es
nclude menu items such as ome allery ontact and nformation
nsure that the nav ar is responsive and functional allo in users to navi ate
et een pa es easily
Footer
footer is a part of a e site that you can find at the ottom of a pa e t has e tra
information that is not in the main part of the pa e ome thin s you mi ht see in a
footer are opyri ht nformation ontact nformation avi ation in s ocial
edia cons in s itemap etc
140 Computer Science , Grade 9
Perform:
Include essential information in the footer such as:
ontact details rovide your email and phone num er for users to reach out
ocial media lin s nclude icons or lin s to your social media profiles
e ace oo itter nsta ram
nership information dd a line indicatin ho o ns the e site and hen
it as created
Home Page
he homepa e is the first pa e you see hen you visit a e site ome pa e is also
no n as the nde pa e t is li e the front door elcomin you in and sho in
you around n the homepa e you ll find menus to e plore di erent parts of the
site lin s to important pa es and hi hli hts of hat the e site is all a out
Perform:
t least ima e should e inserted as a cover ima e of the pa e
ome pa e should contain a elcome messa e section
ome pa e should contain a section for upcomin events
ome pa e should contain a social media icon here it should hyperlin ith
the social media site
ome pa e should contain a footer
Gallery Page
allery pa e on a e site serves as a visual sho case for various forms of
multimedia content ypically it displays collections of ima es videos or other
visual elements related to a specific theme event product or service
a e should contain di erent sections such as vents ead of the epartment
and others
here should e or sections
a e should require at least or photos ith captions hich are needed for
each section
Computer Science , Grade 9 141
Information Page
n this section there should e a static ta le here your information is to e
mentioned sample structure for information pa e is iven elo
Contact page:
here should e form
n the form there should e first name last name phone num er address
email radio utton and drop do n menu and messa e o
here should e a utton to su mit
To complete this project, you need to do the following tasks:
reate a folder for your pro ect and name it my porfolio html
reate four files and name them inde html allery html contact
html and information html and store them in my ro ect folder
reate a file name it style css and store it
in the file to all the files usin the lin ta
dd the asic structure to each file
142 Computer Science , Grade 9
Unit 5 Internet and Social Media
Let’s think!
a o has the internet chan ed the ay e access and share information
compared to traditional methods li e ne spapers and letters in epal
n hat ays do you thin social media has impacted our daily communication
and relationships ith others
c hy do you thin understandin online tools such as e ro sers search
en ines and email is essential for navi atin the di ital orld
e read ne spapers in our daily lives
throu h hich e can et information
from all around the orld hich is
limited ut ith access to the internet
e can read ne spapers from all around
the orld throu h our mo ile phones
ta lets laptops and other electronic
devices
Figure:5.1
Computer Science , Grade 9 143
he nternet is a lo al communication system connectin thousands of individual
net or s formin a vast net or of net or s t facilitates the e chan e of
messa es real time communication data sharin and access to vast information
repositories
Do You Know?
ppro imately illion people use their mo ile to devices access the internet
nternet and social media e plore the foundational concepts overnin online
communication t e ins ith an overvie of the orld ide e e
ro sers search en ines and s tudents delve into remote lo in applications
e protocols and irtual rivate et or s s he unit also emphasi es
the si nificance of email and provides hands on tas s delvin into social media s
diverse applications nline video meetin s are introduced ith e amples and
practical tas s leadin to e plorin lo s and their ey features his comprehensive
unit provides students ith essential insi hts into the interconnected e of the
internet and social media enhancin their a ility to navi ate the di ital landscape
e ectively
5.1 Concept of WWW, Web Browser, Search Engine, and URL
World Wide Web (WWW)
he orld ide e
refers to a net or of interlin ed
hyperte t documents and
multimedia content accessi le
online
sers use e ro sers to search
vie and do nload information
or orld ide e as
developed in the uropean article
hysics a oratory eneva
it erland in he
e has evolved to ecome one
of the most idely utilised nternet
services in recent years Figure:5.2
144 Computer Science , Grade 9
Web Browser
e ro ser is a special computer pro ram
that helps you find and access information on the
internet ro ser is li e a tool that allo s us
to e plore and read information from the e on
our computer t is also used to interpret and open
the documents osaic as the st e ro ser
and oo le hrome afari and o illa irefo
are the most popular ro sers in use today
Figure:5.3
Do you know?
osaic hich is the first e ro ser started developin
in the late hich as founded y arc o ell
ndreessen
Search Engine
search en ine is client side soft are
that helps us find data and information on
the internet ased on ey ords provided
y users hen e type in ords or
phrases it sho s us e pa es related to
hat e are loo in for
Figure:5.4
oo le in aidu and uc uc o are some e amples of popular search
en ines ost search en ines provide not only te t results ut also ima es videos
ne s maps and shoppin services here are also some speciali ed search en ines
such as id e a search en ine for school students
Let’s check!
hich of the follo in is the most popular search en ine
a in oo le c ahoo d icrosoft
earch en ines use advanced techniques to help users find relevant information
online or instance they use al orithms to match ey ords entered y users ith
Computer Science , Grade 9 145
the content on e pa es to chec the relevance of the information found on the
e oreover users can refine their searches usin oolean operators li e
and ensurin that specific ey ords must or must not e present in
the results
dditionally puttin quotes around a phrase narro s do n searches hile ildcard
characters li e roaden them to include variations of a ord sers can also
limit searches to specific e sites usin the site operator or find particular file
types usin filetype follo ed y the e tension li e or
Activity 5.1
Activity Outcome -
nderstand the impact of di erent search operators on search en ine results
y analy in result counts
equired esources o ile phone or computer ith internet access and a search
en ine e oo le etc
pen a search en ine on your device such as oo le
nter the ey ord search engine usin di erent search operators as instructed
elo
fter each search note do n the result count displayed y the search en ine
Without Quotes ype search en ine ithout any quotation mar s
Using Quotation Marks (“ “) ype search en ine ith quotation
mar s around the entire phrase
Using “filetype:” Operator ype search en ine pdf to loo for
files related to the term
sing Asterisk (*) ype search en ine to include variations of the
ey ord
Quote Keyword Result number
ithout usin qoute search en ine
sin uote search en ine
sin filetype uote search en ine pdf
sin uote search en ine
Result: roup discussion on the impact of di erent search operators and ho
they in uence search results ith each roup sharin their recorded data
146 Computer Science , Grade 9
URL
niform esource ocator is li e an internet
address that helps you find and access thin s online
t is hat you type into a e ro ser to reach specific
resources li e e sites or files t is commonly used in
e ro sers to navi ate to specific e pa es
Figure: 5.5
Here are the key components and concepts associated with a URL:
a Scheme/Protocol: t is the method used to access thin s such as e pa es
secure pa es or files
Domain: his is the server s name li e e ample com can e
a part of it and e ample com is the main name
c Top-Level Domain (TLD): t s the last part of the domain sho in the
e site type li e com or or edu
d Path: his is here the specific thin is on the server li e path to resource
Here’s an example of a complete URL and its components:
Figure: 5.6
Activity 5.2
Activity Outcome -
ccess and analy e online resources o servin availa le content and resource
types on the specified e site
Required Resources: Personal computer or mobile phone with internet access,
etc.
pen a e ro ser on your device
Computer Science , Grade 9 147
nter the follo in in the address ar https mysecondteacher com np
teachin resources
evie the content and teachin resources availa le on the pa e notin
specific types of resources topics covered and any additional o servations
ecord your findin s in the ta le elo
URL Result/Findings
https mysecondteacher com np teachin resources
Result: roup re ection on the types and quality of resources found on the pa e
ith discussion on their potential usefulness for academic learnin
5.2 Concept of Remote Login
Remote Login
Figure: 5.7
emote o in is a process in hich a user can lo into a remote site i e computer
and use services that are availa le on the remote computer ith the help of remote
lo in a user can understand the result of transferrin and the result of processin
from the remote computer to the local computer
Examples of Remote Login
Some examples of remote login software are:
AnyDesk: ny es is a remote des top soft are application that allo s users to
access and control a computer or device from another location
148 Computer Science , Grade 9
TeamViewer: eam ie er is another soft are that allo s us to remotely access
and control any computer or device eam ie er is similar to ny es ut it also
has features such as online meetin s video calls and cloud stora e
Activity 5.3
Activity Outcome -
earn to set up an nydes account and use it to connect to a remote computer
equired esources ersonal computer or mo ile phone ith internet access
etc
Procedure:
Step 1: Sign in/create an account.
isit nydes and do nload the application on your
pen nydes and choose to si n in usin your oo le account or create a
ne account if you do not have one
Step 2: Connect from local to remote computer
pen the nydes application on your computer
opy your nydes ddress from the application indo
lic the nvite utton located near the address field
aste the ddress of another nydes account ith hich you ant to
connect
elect the profile for creen harin
lic on nvite and ait for the other user s approval to e in the remote
session
Result: eacher led discussion and re ection on the e perience addressin any
issues encountered and clarifyin remote access est practices and security
considerations
Computer Science , Grade 9 149
5.3 Concept of protocols
Web protocols
protocol is li e a set of rules that uides
computers to communicate with each other on
the internet t defines ho data is or ani ed and
moved et een computers ma in sure it is done
e ciently safely and relia ly i erent protocols
are used for various online activities li e sendin
files ro sin the e emails and streamin
Figure:5.8
Examples of web protocols
ome of the e amples of e protocols are
HTTP
stands for yperte t ransfer rotocol
hich is a set of rules for ho e ro sers
and servers communicate ith each other t
or s li e a request and response system the
ro ser as s for somethin and the server ives
it o ever ecause isn t secure others
mi ht e a le to see or chan e the information
ein sent
Figure:5.9
HTTPS
or yperte t ransfer rotocol ecure is a protocol
ensurin secure communication et een e ro sers and
servers his protocol is employed for the safe transfer of
various resources such as e pa es from a e server to
a e ro ser
Figure:5.10
150 Computer Science , Grade 9
Activity 5.4
Activity Outcome -
eco ni e the di erence et een and protocols y identifyin
e sites usin each protocol
Required Resources: ersonal computer or mo ile phone ith internet access
etc
Procedure:
pen a e ro ser on your device
se a search en ine to find one e site that uses HTTP (without encryption)
and another that uses HTTPS ith encryption
ote the of each e site o servin the security indicators such as a
padloc icon present in sites ut not ones
ecord the s in the ta le elo
Protocol Website URL
Result: roup discussion on the si nificance of for security focusin on
data encryption privacy and protection a ainst potential threats associated ith
5.4 Email and its uses
Email
mail short for electronic mail is a popular
ay for people to e chan e di ital messa es
usin devices li e computers ta lets and
smartphones t consists of a sender a
recipient a messa e ody and sometimes
attachments
Figure: 5.11
Computer Science , Grade 9 151
Figure: 5.12
Here,
n email the o field indicates the primary recipient hile c car on copy
allo s sendin a copy to additional recipients ho are not the main addressee ut
should still e informed cc lind car on copy serves a similar purpose as c
ut hides the additional recipients from others
ommon email platforms li e utloo facilitate various actions such as eply
for respondin to a messa e or ard for sharin it ith others dv for
mar in an email as an advertisement is for mar in it as spam or un anted
and ttach for includin files ith the messa e hese features contri ute to the
versatility and functionality of email communication
Uses of email
Some of the uses of email are:
a Personal Communication: mail facilitates sharin thou hts and ne s
con ratulatin invitin and e pressin sympathy ith friends and family
Education: mail provides students ith a convenient ay to as questions
and communicate ith mentors teachers and classmates
152 Computer Science , Grade 9
c Business: mail is essential for usiness communication connectin ith
suppliers investors and customers and facilitatin transactions and rand
promotion
d Marketing: mail is an e ective mar etin tool distri utin surveys o ers
and ne sletters to enhance client satisfaction and loyalty
e Entertainment: mail allo s fans to stay connected ith their favourite
cele rities receive updates and participate in fan clu activities
Activity 5.5
Activity Outcome -
earn to rite a ell structured formal email to inform a teacher a out an
a sence
Required Resources: ersonal computer or mo ile phone ith internet access
etc
Procedure:
pen your email application
rite a clear subject line li e sence otification for ate s
tart ith a polite greeting e ear eacher s ame
n the body of the email include
eason for your a sence e illness family commitment
he specific date s you ill e a sent
rief statement a out catchin up on missed or or assi nments
onclude ith a closing statement e han you for your understandin
Sign off ith est re ards or incerely follo ed y your full name and
class information
Result: eacher revie s students emails providin feed ac on the formality
clarity and completeness of each email draft
5.5 Appropriate usage of social media and safely accessing web sites
Social media
efore the invention of the internet people used to communicate throu h paper
Computer Science , Grade 9 153
mail he use of communication throu h such means ould sometimes consume a
lot of time resultin in late delivery ith the invention of various social applications
e can no send messa es in one clic
ocial media is li e a i online community here people can connect share and
tal to each other e can ma e friends share pictures videos and messa es and
stay updated on hat s happenin ith people e no or thin s e re interested
in amples include ace oo nsta ram napchat itter and hats pp
Let’s learn!
oo up and research the fi ure and ans er the follo in questions
a hat is in ed n
o you no in ed n provides learnin platform
c o can e ma e the est in ed n profile
Pros of social media
a Global Connectivity: t ena les instant communication and connection
lo ally fosterin relationships
Information sharing: t provides a po erful platform for sharin information
and ne s and promotin social causes
c Business opportunities: t facilitates mar etin and rand e posure for
usinesses reachin a vast audience
d Diverse content: t o ers entertainment educational content and ne s
caterin to a ide ran e of interests
e Self-expression: t provides individuals ith a space for sho casin talents
and e pressin creativity
f Real-time updates: t serves as a valua le source for real time updates and
information
Cons of social media
a Isolation and loneliness: espite connectivity online interactions may
contri ute to feelin s of isolation and loneliness
Misinformation: he spread of fa e ne s and misinformation is a si nificant
dra ac
154 Computer Science , Grade 9
c Cyberbullying: ocial media can e a platform for cy er ullyin harassment
and privacy invasion
d Mental health impact: cessive use of social media may lead to mental
health issues such as an iety and depression
e Productivity loss: he addictive nature of social media can result in
productivity loss
f Body image issues: requently seein carefully selected content on social
media can ma e people feel ad a out themselves and lead to concerns a out
their ody ima e and self esteem
Activity 5.6
Activity Outcome -
ocate ey contact information for the y er ureau of epal includin its
e site email and contact num er
Required Resources: ersonal computer or mo ile phone ith internet access
etc
Procedure:
pen a search en ine on your device e oo le
ype the ey ords cy er ureau of epal into the search ar
dentify and note the follo in details a out the y er ureau of epal
Link of the Website: [Link]
● Email Address of the Cyber Bureau of Nepal
● Contact Number of the Cyber Bureau of Nepal
ecord your findin s in the ta le elo
in of the e site nepalpolice ov np
mail of y er ureau of epal
Contact Number of cyber bureau
of epal
Result: roup discussion on the importance of no in ho to contact cy er
authorities and hen it may e necessary to reach out to the y er ureau
Computer Science , Grade 9 155
5.6 Introduction to video conferencing tools
Concept of online video meeting
Fun fact!
he first video call as made et een itts ur h ayor eter laherty and
hairman and ohn arper of lcoa on une
n online video meetin is a ay of tal in to each
other over the internet where we can see and hear
each other at the same time t s ind of li e havin
a chat face to face ut instead of ein in the same
room e re loo in at each other on a computer or
phone screen
Figure: 5.13
hen participatin in online video meetin s one needs to o serve proper
etiquette ethics and dressin sense he etiquette includes ein punctual mutin
microphones hen not spea in to minimi e ac round noise and actively
participatin in discussions i e ise the ethics in online meetin s include ein
respectful of others opinions avoidin disruptive ehavior and maintainin a
professional attitude dditionally students should e mindful of their dressin
sense earin suita le formal attire helps create a positive and respectful online
environment contri utin to a successful virtual meetin e perience
Examples of online video meetings
Some examples of online video meetings are:
a Zoom: oom is a soft are that allo s us to host and oin online video meetin s
ith up to participants t is a idely used video conferencin platform that
ena les users to conduct virtual meetin s e inars and online colla oration
t also allo s us to record and save the meetin s for later vie in or sharin
Google Meet: oo le eet is a video conferencin platform developed y
oo le t is desi ned for virtual meetin s remote colla oration and online
communication
c Microsoft Teams: icrosoft eams is a colla oration platform developed
y icrosoft t is desi ned to facilitate communication colla oration and
team or ithin or ani ations t also allo s us to record and save the
meetin s to ne rive or hare oint
156 Computer Science , Grade 9
Activity 5.7
Activity Outcome -
earn to set up mana e and invite participants to a oo le eet session
Required Resources: omputer or mo ile device ith internet access and a
oo le account etc
Procedure:
Step 1: Sign in/create an account.
isit oo le eet
i n in usin your oo le account or create a ne account if you do not have
one
Step 2: Start a meeting.
lic on tart a eetin or e eetin to e in a session
llo the ro ser or app to access your camera and microphone if prompted
lic on oin o to o cially start the meetin
Step 3: Share the meeting link.
nce the meetin has started copy the meetin lin from the screen
hare the lin ith participants throu h email or messa in
lternatively use the option to invite participants directly y enterin their
email addresses
Step 4: Add participants during the meeting.
urin the meetin clic on the articipants icon
elect nvite to add participants y their email addresses
Result: eacher moderated re ection on the ease of settin up and mana in
online meetin s ith tips for e ective virtual communication and meetin
mana ement
Computer Science , Grade 9 157
5.7 Concept of blogs and its features
Concept of blog
ome of us have a ho y of e plorin di erent places and capturin those special
moments on our cameras or smartphones hose captured videos or photos can
e turned into a lo and e can upload them on di erent social media platforms
and e sites e can also ain idespread fame and capital y carryin out such
activities
lo is li e an online ournal or diary here people can share their thou hts
ideas e periences or information on a specific topic lo s can cover a ide ran e
of su ects such as personal stories ho ies travel technolo y or any other area
of interest
Features of blog
Some of the features of a blog are:
a Posts: lo s consist of individual entries called posts ach post focuses on a
specific topic or idea
Authorship: ach post is ritten y an author ho is usually the person
maintainin the lo uthors share their thou hts e periences or no led e
c Comments: eaders can leave comments on lo posts creatin a space for
interaction and discussion
d Categories: lo s often or ani e posts into cate ories ased on topics his
helps readers find content related to their interests
e Archives: lo s have archives that allo users to access older posts t is li e
a di ital history of the lo s content
f Tags: lo ers use ta s to la el posts ith ey ords ma in it easier for
readers to search for specific topics
Images and multimedia: lo posts can include ima es videos and other
multimedia elements to enhance content and en a e readers
h Social sharing: lo platforms usually include options for readers to share
posts on social media spreadin the content to a ider audience
i u scri e eaders can su scri e to a lo to receive updates hen ne posts
are pu lished
158 Computer Science , Grade 9
Exercises
1. Write full forms of the following abbreviations.
a c
d e f
2. Choose the correct answer.
a hich of the follo in is a correct term that descri es the multimedia
content and interlin ed collection of hyperte t documents on the nternet
i nternet ii orld ide e
iii e ro ser iv earch n ine
he main purpose of the internet is to
i send emails ii play ames
iii access and display hyperte t documents on the e
iv edit ima es
c hich of the follo in is a secure version of providin encrypted
communication?
i ii iii iv
d is the primary purpose of a
irtual rivate et or
i ecurely connect to the internet and access resources
ii used for online meetin s
iii lay online ames
iv dits ima es online
Computer Science , Grade 9 159
e he main purpose of social media is
i editin documents
ii connectin sharin and tal in to others online
iii playin online ames
iv sendin emails
f hich of the follo in is not an e ample of a
i ord ii oo le eet
iii press iv uper unlimited pro y
hich of the follo in applications are used for online meetin s
i oo le eet ii oom
iii ype iv ll of the a ove
h are individual entries called in a lo
i a es ii ections
iii osts iv rticles
i hy is lo in used
i hare lo posts on social media
ii llo readers to interact and discuss
iii ate ori e posts ased on topics
iv ll of the a ove
3. Write short answers to these questions.
a hat is the nternet rite its t o uses
hat is a ist out the components of
160 Computer Science , Grade 9
c hat is a e ro ser ive an e ample
d rite do n some e amples of online meetin platforms
e hat are e rotocols ist out the e amples of the e rotocols
f rite do n some uses of email
4. Write long answers to these questions.
a efine earch n ine hat are the uses of search en ines rite ith an
e ample
plain the concept of emote o in
c rite do n the di erence et een and s
hat is social media ist out the uses of social media ith its e amples
h efine lo s rite do n the advanta es and disadvanta es of lo in
5. Lab Activities
a) Apply digital signature and secure email using Gmail, Outlook or similar
mail system.
Step:
pen your mail account
o to ettin s
lic on ee all settin s
lic on the eneral
o to i nature here you sa the option create ne
lic on reate e option dd ne si nature ype i nature name
lic on reate option
fter that on the left side the content area is present on the content
area ype the ame ddress and o n positions and or ani ation
name too
Computer Science , Grade 9 161
fter the area is filled then o to the ello of the pa e and enter on
the save chan e
b) Demonstrate the mechanism of searching for different learning
materials from the internet.
Step:
pen your e ro ser aunch your preferred e ro ser e
oo le hrome o illa irefo afari
o to earch en ine avi ate to a search en ine s e site such as
oo le for this demonstration e ll use oo le
nter your search query n the search ar type your learnin query
or e ample let s say you re loo in for materials on ython
pro rammin for e inners
evie search results ress nter or clic on the search icon to
vie the search results
plore results ro se throu h the search results to find relevant
learnin materials ay attention to the titles and snippets provided
efine your search f the initial results are not hat you re loo in
for consider refinin your search query or instance you mi ht add
specific terms li e ython pro rammin tutorials or ython
asics
se filters tili e search en ine filters to narro do n results ou
can filter y type videos ima es ne s or time past hour past
hours past ee to et the most relevant content
isit e sites lic on the search result lin s to visit e sites that
seem promisin oo for reputa le sources such as educational
institutions o cial documentation or ell no n learnin
platforms
o nload or save materials nce you find the desired learnin
materials you may do nload s videos or other resources as
needed ollo the specific instructions on the e site to access or
save the content
162 Computer Science , Grade 9
plore additional resources croll throu h the search results
and e plore di erent e sites to ather a variety of learnin
materials onsider oo mar in useful e sites for future
reference
c) Creating a profile on other platforms:
Steps:
hoose the platform dentify the social media platform you ant to
oin e nsta ram itter
isit the platform s e site o to the o cial e site of the chosen
platform
i n up ollo the si n up process providin the required
information
ustomi e your profile dd a profile picture io and other relevant
details
onnect ith others ind and connect ith friends family or other
users plore and ontri ute tart e plorin content follo in
accounts and contri utin to the platform
d) Create a virtual meeting using any application such as Zoom, Meet,
or Teams.
Zoom
Step 1: Sign in/create an account.
isit the oom e site https oom us
i n in if you have an account or create a ne account
Step 2: Schedule a meeting.
fter lo in in clic on chedule a e eetin or ost a
eetin in the top ri ht corner
ill in the meetin details such as topic date time and other settin s
Computer Science , Grade 9 163
lic ave to schedule the meetin
Step 3: Invite participants.
nce the meetin is scheduled you ll see options to invite
participants
end invites via email copy the invitation lin or use other options
Step 4: Start the meeting.
t the scheduled time return to the oom e site or open the oom
app
lic on tart to e in the meetin
Project work
Project Outcome -
earn to create a ou u e channel upload videos and en a e ith the
ou u e community
Required Resources: omputer or mo ile device ith internet access oo le
account video files and ima es for channel customi ation etc
Procedure:
Step 1: Sign in to Google.
o to oo le s si n in pa e
f you already have a oo le account si n in usin your credentials
f you don t have a oo le account clic on reate account and follo the
steps to set up a ne oo le account
emem er that ou u e requires a oo le account since it is a oo le
o ned platform
Step 2: Go to YouTube.
pen your e ro ser and o to ou u e
164 Computer Science , Grade 9
i n in ith your oo le account if you aren t si ned in automatically
Step 3: Create a channel.
lic on your profile picture in the top ri ht corner of the ou u e homepa e
rom the dropdo n menu select reate a channel
ou ll e prompted to set up your channel clic on et tarted to e in
Step 4: Set up your channel.
hoose a unique channel name that re ects the type of content you plan to
upload
pload a profile picture that visually represents your channel e a lo o or
relevant ima e
ustomi e your channel settin s y follo in the prompts his includes
privacy settin s your display name and any other initial confi uration
options
Step 5: Upload a video.
repare a video you ant to share on your channel his can e a short
introduction tutorial or any content relevant to your theme
lic on the camera icon ith a plus at the top of the pa e and select
pload video
elect the video file from your device and follo the prompts to add a title
description and ta s to improve visi ility
evie ou u e s video settin s for privacy u lic unlisted private a e
restrictions and moneti ation if applica le
Step 6: Customize your channel.
o to the ou u e tudio found in your profile dropdo n to access channel
customi ation options
dd a channel description to inform vie ers a out the content they can
e pect
Computer Science , Grade 9 165
ustomi e your channel layout e featured sections to ma e it easy for
visitors to ro se your videos
dd lin s to your social media profiles or e site y oin to the asic
nfo section in the customi ation menu
pload channel art anner for a visually appealin homepa e
Step 7: Start sharing.
hare your video on social media platforms or ith friends to increase
visi ility
n a e ith the ou u e community y respondin to comments li in
relevant content and colla oratin ith other creators
se the ou u e tudio to monitor vie er statistics and et insi hts into your
audience
Result:
e ect on your e perience settin up the channel customi in it and sharin
content onsider hat types of videos you ant to produce in the future and ho
you ill en a e ith your audience
166 Computer Science , Grade 9
Unit 6 Cyber Security and Digital Citizenship
Let’s think!
a iscuss hy cy ersecurity is essential for individuals and usinesses in epal
plain ho you thin your online activities impact your privacy and security
c iscuss the responsi ilities that come ith ein a di ital citi en
6.1. Concept of cybersecurity
y ersecurity refers to the practice of protectin computer systems net or s and
di ital information from theft dama e unauthori ed access and various forms of
cy erattac very day there are a lot of cy erattac s happenin online hese
attac s can tar et i companies re ular
people and small usinesses hey can cause
a lot of dama e and can happen to anyone
any here in the orld
eople and usinesses can use di erent tools
and methods to eep their di ital information
safe and defend a ainst cy er threats here
are various types of cy ersecurity li e net or Figure 6.1
Computer Science , Grade 9 167
security application security information security and operational security t s
crucial for everyone to reali e ho important cy ersecurity is and to ma e sure
they re usin all the methods availa le to defend a ainst cy erattac s
Let’s check!
hich of the follo in is not cy er security
a et or security pplication security
nformation security c uantum security
6.2. Concept of cybercrime
y ercrime simply refers to the criminal activities carried out y means of
computers or the nternet hen someone uses a computer to do ad thin s it
can hurt other people s safety and money y er attac s come in di erent forms
li e stealin someone s identity tric in them ith fa e emails stoppin e sites
from or in stealin information puttin ad soft are on computers ithout
permission or ta in over social media accounts to post ad stu n epal the
lectronic ransaction ct handles controllin the cy ercrime related
issues and helps in draftin and implementin la s a ainst cy ercrime
6.3 Prevention methods from cybercrime
y ercrime is a serious threat e deal ith daily and even cy ersecurity e perts
can stru le to fi everythin hat s hy it s ise to try to stop cy ercrime efore
it starts ere are some steps to prevent it
a. Use a strong password.
ass ord is a set of alphanumeric characters usually used to conform users
identity ass ord is ust as e secure our homes ith loc s safe uardin our
di ital assets requires stron pass ords to protect
valua le data from threats tron unique pass ords
should e used for online accounts and devices
chan ed re ularly and not shared hese pass ords
alon ith usernames are called credentials and are
essential for accessin email e sites financial
accounts and more eepin pass ords secure helps
prevent unauthori ed access and misuse of personal
information Figure 6.2
168 Computer Science , Grade 9
Here are some tips to ensure our passwords are secure and strong:
a o not use a sequence for e ample or a cd hich can e easily uessed
ry to include num ers sym ols and oth uppercase and lo ercase letters
c void usin ords that can e found in the dictionary or e ample ords
such as admin and password are considered very ea pass ords
d se a lon er pass ord our pass ord should e at least si characters lon
althou h for e tra security it should e even lon er
e se om ination of pper ase and o er case letters includin um ers
and special characters
Fun fact!
q erty and pass ord are li e the ever reen roc stars of the
di ital orld espite ein a out as secure as leavin your front door ide open
in a usy city they still mana e to roc the charts as the most used pass ords t s
li e they re the classics that never o out of style even thou h security e perts
are constantly screamin for a chan e in tune
Multi-factor authentication (MFA)
ulti factor authentication is an
authentication method that adds an e tra layer
of security y requirin users to provide t o or
more verification methods to access an online
account or application t s considered one of the
most important security measures because even
if someone no s your pass ord they ould
still need access to your mo ile phone or require
your fin erprint or face scan to ain access to your Figure 6.3
account
Types of multifactor authentication
1. Thing you know
a ass ord in
Computer Science , Grade 9 169
2. Things you have
a ad e martphone
3. Things you are
a iometrics such as fin erprint oice c etina of eye
Software updates
eepin your operatin system and internet security up to date is e tremely
important a e sure to re ularly update your applications and operatin system
such as indo s ndroid i inu and others ith the latest system updates
urnin on automatic updates can help prevent potential attac s on outdated
soft are
Authentication
dentification of an individual usually ased y username and pass ord is no n
as authentication avin a stron authentication system in place ma es it di cult
for others to access your computer system ithout your permission
Use of Firewall
fire all is a security tool that filters net or connections to loc unauthori ed
users from accessin a device net or or private data t can come in di erent
forms such as hard are soft are or as a feature ithin an operatin system li e
indo s ire all or i ire all na lin a fire all on a device helps protect it
from un anted internet tra c his helps prevent computers from viruses
Figure 6.4
170 Computer Science , Grade 9
Activity 6.1
Activity Outcome
ain hands on e perience ith antivirus soft are and fire all settin s
understandin their functions in protectin devices from threats
Required Resources: omputer or device ith antivirus soft are and fire all
options such as indo s efender or a third party antivirus nternet connection
if needed for updates ro ector or screen optional for class demonstration
etc
Part 1: Understand use of antivirus software
Procedure:
Open the antivirus program: ou should open the antivirus soft are installed
on the classroom s device f there isn t one they may use indo s efender or
a free trial of an antivirus pro ram that you can use
a) Demonstrate a quick scan:
un a quic scan of the system and o serve any threats detected
b) Full scan option:
ee the di erence et een a quic scan and a full scan
c) Review and quarantine threats:
f any threats are detected revie the results and quarantine or removal the
viruses
d) Update the antivirus:
pdate the virus definitions manually if and understand that eepin soft are
updated is crucial for protectin a ainst ne threats
Part 2: Understand use of a firewall (software or hardware)
procedure:
a) Access firewall settings:
pen fire all settin s on the device e in indo s access indo s
efender ire all throu h ontrol anel
b) Configure basic firewall rules:
llo or loc applications from accessin the net or usin fire all rules
Computer Science , Grade 9 171
or e ample loc an application temporarily and sho ho to un loc it
after ard
c) Demonstrate inbound and outbound rules (if available):
reate custom in ound or out ound rules to control access to specific services
or addresses
d) Enabling/disabling the firewall:
se the option to turn the fire all on or o ut e plain the ris s of disa lin it
and emphasi e the importance of eepin it ena led
Result: oderated re ection and discussion a out your e perience usin these
tools
6.4 Safe web browsing techniques
n today s di ital orld the internet is no lon er a safe place for individuals or
usinesses here are a num er of e sites hac ed daily part from these
cy erattac s and ransom are attac s also happen daily o it is crucial to have a
ood no led e a out cy ersecurity practices o prevent such attac s here are
some safe ro sin techniques that help minimi e cy er threats
a. Use a secure connection
A secure connection refers to the private communication
et een your device and a server usin encryption
ncrypted communication prevents anyone from
listenin to or chan in your data ou can also chec
if a connection is secure y loo in for a loc icon or Figure 6.5
a https prefi in the address ar of a e site sin a
virtual private net or from trusted providers li e ord roton
and o illa can also protect the user s privacy to some e tent
b. Use a secure browser
A secure browser protects user privacy and
security hile surfin the e he secure
ro ser has features such as private ro sin
trac in protection d loc in pass ord
mana ement etc ome e amples of secure Figure 6.6
ro sers are o illa irefo oo le hrome afari icrosoft d e pera
rave etc
172 Computer Science , Grade 9
c. Use a secure search engine
secure search en ine is a e ased tool that
allo s users to search for information on the
internet hile prioriti in privacy and security
t may also filter out harmful or inappropriate
e sites from the search results ome e amples
of popular search en ines are oo le in and Figure 6.7
uc uc o
Do you know?
oo le rei ns as the undisputed champion of search en ines across the lo e
dditionally a hoppin of internet users prefer to surf the e usin
oo le hrome ma in it the top choice for e ro sin orld ide
d. Use secure websites.
secure e site prioriti es user privacy and security durin visits y
incorporatin various features such as encryption authentication and
verification o determine if a e site is secure loo
for indicators li e a loc icon or https prefi in the
address ar indicatin that the connection is encrypted
dditionally revie the e site s privacy policy terms
of service and user revie s to chec ho it handles your
data and ensures security measures are in place
Figure 6.8
Activity 6.2
Activity Outcome -
emonstrate safe ro sin techniques y follo in recommended security
practices
Required Resources: omputer ith internet access ro ser application
if needed ad loc er soft are or e tensions instructional materials etc
Procedure:
our teacher ill introduce various safe ro sin techniques and demonstrate
each step
Computer Science , Grade 9 173
ou ill or individually or in pairs to practice the follo in techniques
a) Check browser version and updates: erify that the ro ser is up to date
and perform updates if necessary
b) Exercise caution with downloads: evie and discuss est practices for
do nloadin files and applications securely
c) Clear browser cookies: earn to delete ro ser coo ies to maintain privacy
d) Use an Ad blocker: nstall or ena le an ad loc er to protect privacy from
invasive ads
e) Create strong passwords and enable MFA: ractice creatin secure
pass ords and settin up ulti actor uthentication here availa le
f) Use a trusted VPN (if required): Learn how to set up and connect to a
relia le for added security hen needed
Result: oderated re ection and discussion for feed ac on each technique
practiced addressin questions and reinforcin safe ro sin practices
6.5 Concept of Digital Citizen
i ital iti en is someone ho no s ho to use
the internet and di ital technolo y responsi ly hey
actively en a e in the di ital society y creatin
colla oratin and enefitin from di ital content
and resources o e a ood di ital citi en consider
follo in these uidelines
a hin efore you post on social media platforms Figure 6.9
e mindful of hat you share and its potential
impact
void sharin personal information e cessively to reduce the ris of identity
theft
c se multiple search en ines to limit trac in of your search history and enhance
privacy
d e ularly chan e pass ords to ma e it harder for cy ercriminals to access and
steal your data
e eport any unla ful or inappropriate ehavior to the authorities to help
maintain a safer online environment
174 Computer Science , Grade 9
6.6 Concept of Netiquette and online behaviors
etiquette derived from net or and etiquette refers to a set of uidelines
for appropriate online ehavior hile internet ethics focuses on the proper use of
online resources in di ital communities t s a recommended rule for oth personal
and professional internet usa e uidin users on platforms li e ace oo iscord
and online forums ust li e in person manners online manners are equally
important in family society and professional settin s espite challen es in online
communication the fundamental principle of treatin others ith respect remains
constant
Here are some examples of good netiquette and online behavior:
ave respectful communication
void o ensive content
espect privacy don t share personal info
void spammin or oodin
ive credit hen sharin others or
hin efore postin
eport a usive ehavior
e open to constructive criticism
aintain a positive presence online
6.7 Concept of digital footprint and privacy in online
ust li e hen you al on sand or mud each step you
ta e leaves an impression indicatin here you ve een
and hat you ve done our di ital footprint is li e
leavin footprints as you al throu h the internet t
sho s here you ve een and hat you ve done online
Figure 6.10
di ital footprint is defined as an information record
enerated y an individual s online activities hese activities include online
searches social media visits online shoppin phone calls sendin emails etc
di ital footprint is sometimes called A Digital Shadow” or “Electronic
Footprint very internet activity creates some sort of di ital footprint that can e
used to trace a person s online activities as ell as their devices here are t o types
of di ital footprints and they are
Computer Science , Grade 9 175
Active digital footprints: t comprises information that an internet user
no in ly leaves ehind ince the user no in ly provided information the
user is also informed of the di ital footprint they have left ehind ocial media
posts phone calls and emails are a fe e amples of active di ital footprints
Passive digital footprints: hese consist of information that an internet user
un no in ly leaves ehind hese inds of footprints are di cult to monitor
and mana e since they mi ht e o tained ithout the approval of the user
e searches online shoppin location data and fitness trac ers are some
e amples of passive di ital footprints
Activity 6.3
Activity Outcome -
nderstand the concept of di ital footprints y atherin and analy in
information a out di ital identities and device usa e
Required Resources: ote oo or di ital spreadsheet for data collection
internet ena led device etc
Procedure:
our teacher ill divide you in pairs or small roups and you ill collect di ital
footprint information from classmates
a ou ill have to collect the follo in information
Name: irst and last names
Email ID: rimary email address
Device: ypes of devices they frequently use e smartphone laptop
Social Media Username: ain usernames or handles used on social
media platforms
omplete the follo in data ta le
Name Email ID Device Social Media Username
c) Privacy Reminder: tudents should o tain permission from their peers efore
collectin and recordin their information and handle this data responsi ly
Result: oderated discussion on di ital footprints privacy and online safety
encoura in students to re ect on ho their information is shared and used online
176 Computer Science , Grade 9
nline privacy is a fundamental ri ht in today s di ital orld focusin on
safe uardin one s private life home and communication pecifically it pertains to
the protection of an individual s personal information stored on the internet includin
data on di ital devices and services li e e searches and social net or in sites
rivacy concerns are a si nificant issue in the modern era ith di ital footprints
servin as the primary avenue for cy ercriminals to tar et private data hile there
are advanta es to di ital connectivity such as enhanced communication and access
to information there are also disadvanta es includin the ris of privacy reaches
and unauthori ed access to personal data
Activity 6.4
Activity Outcome -
onduct research and identify di erences et een re ular ro sin mode
and inco nito mode
Required Resources: omputer or mo ile device ith internet access etc
Procedure:
our teacher ill divide you in pairs or small roups and you ill collect di ital
footprint information from classmates
a) Research: ndividually or in pairs you ill conduct research on inco nito
mode e plorin its purpose and functionality
Focus points should include:
o inco nito mode or s
ey di erences from re ular ro sin mode
imitations of inco nito mode in terms of privacy and security
b) Practical Exploration:
pen a ro ser in re ular mode and note do n ey features visi le history
and saved data such as coo ies saved pass ords
itch to inco nito mode and compare di erences focusin on hat data is
saved visi ility of ro sin history and session ehavior
Computer Science , Grade 9 177
c) Complete the Following Comparison Table:
Regular Browsing Mode Incognito Mode
aves ro sin history and coo ies oesn t save ro sin history
etains lo in sessions and form data nds lo in sessions after closin
Incognito Mode Shortcut Key:
hortcut eys for inco nito mode
hift trl
Result: oderated discussion on the advanta es and limitations of usin
inco nito mode ith students sharin o servations and insi hts
Advantages:
a. Health monitoring
mart atches and health applications utili e di ital footprints to monitor and
analyse users fitness and health data aidin in etter health mana ement
b. Social connections
i ital footprints help uild and foster connections ith others particularly
on social net or in platforms facilitatin communication and relationship
uildin
c. Targeted advertising
ompanies can tar et advertisements ased on customer ro sin ehaviors
improvin the relevance of ads and potentially increasin sales e ectiveness
d. Law enforcement support
olice can utili e online records to aid in investi ations and prevent ille al
activities levera in di ital footprints to ather evidence and ensure pu lic
safety
178 Computer Science , Grade 9
Disadvantages
a. Security vulnerabilities
i ital footprints e pose individuals to security ris s ena lin others to trac
their online activities ith ease potentially leadin to privacy reaches and
identity theft
b. Legal and ethical concerns
he use of di ital footprints raises le al and moral questions re ardin the
handlin of sensitive information promptin de ates over privacy ri hts and
data protection la s
c. Exploitative business practices
usinesses may profit from sellin user data ithout adequately compensatin
individuals for the value of their private information raisin concerns a out
fairness and ethical usiness practices
d. Cybercriminal exploitation
ac ers can e ploit the data contained in di ital footprints to perpetrate fraud
and other criminal activities posin si nificant ris s to individuals financial
and personal security
e. Spying and online abuse
etailed di ital footprints can e used for spyin and online a use eopardi in
individuals safety and e posin them to various forms of cy er harassment
and e ploitation
Here are some practical steps you can take to protect yourself from the risks
of digital footprints:
a Know security rules: nderstand ho your personal information is handled
y e sites and services you use
Update privacy settings: d ust privacy settin s on social media to control
ho can see your information
Computer Science , Grade 9 179
c Secure devices: se stron unique pass ords for each account and ena le
e tra security measures li e multi factor authentication
d Remove old accounts: elete unused online profiles to reduce e posure of
personal information
e Update software: eep your devices and apps updated to fi security a s
f Disable location tracking: urn o location services on apps and devices
hen not needed to prevent constant trac in
Do you know?
f a person pu lishes or displays material a ainst morals etiquette or hatred on a
computer internet and other electronic media the culprit can e punished ith a
fine of la h rupees or imprisonment for up to years or oth as per lectronic
ransactions ct
Exercises
1. Write full forms of the following abbreviations:
a c
d e o f
2. Choose the correct answer.
a he full form of is
i lectronic ransaction ct
ii lectric ransmission ction
iii lectronic ransform ct
iv lectronic ransaction areness
ho re isters complaints of cy ercrime in epal
i epal elecommunication uthority
ii ocal police stations
180 Computer Science , Grade 9
iii y er ureau of epal
iv he inistry of ome a air
c is not an e ample of antivirus soft are
i aspers y ii ire all
iii vast iv orton
d hich of the follo in is not a cy ercrime
i ccessin child porno raphy contents ii uthentication
iii hishin iv rute force attac
e y er la is commonly no n as
i la of the internet ii di ital e islation
iii prevention method of cy er crime iv ays of usin the internet
f he lectronic ransactions ct of epal also consists of
i constitution ii cy er la s
iii computer soft are iv transaction records
he com ination of username and is asically no n as a user
credential
i pass ord ii security question
iii iometric iv phone num er
h hen as the lectronic ransactions ct pu lished
i ii iii iv
3. Write short answers to these questions.
i hat is y ersecurity
ii plain y er a y relatin it ith the constitution
Computer Science , Grade 9 181
iii hat is a ire all hy is it di erent from antivirus soft are
iv ou use di ital devices on a daily asis hat do you no a out di ital
society?
v hat is mal are rite do n the di erent types of mal ares
4. Write long answers to these questions.
a efine mal are and descri e its types
plain a out di ital footprint and rite the advanta es and disadvanta es
of it
c plain the safe ro sin techniques
d efine y ercrime plain the prevention method from cy ercrime
e plain a out netiquette uidelines
Project work
Project Outcome -
onduct research on cy ercrime trends e plore real orld case studies and
develop a areness of prevention strate ies
Required Resources: nternet ena led device laptop ta let or computer
access to online research resources or data ases note oo or di ital document
for notes etc
Procedure:
our teacher ill divide you in pairs or small roups
a) Topic Selection and Group Division:
he teacher ill assi n you to roups ith each roup focusin on one
specific type of cy ercrime such as phishin identity theft ransom are
social media hac in or online scams
b) Research Phase:
ach roup ill conduct online research to find recent case studies
articles and reports a out their assi ned type of cy ercrime
182 Computer Science , Grade 9
ather information on
o efinition and characteristics of the specific cy ercrime
o Real-life case study: n e ample here the cy ercrime impacted
individuals or or ani ations
o Consequences: he e ects on victims and or ani ations such as
financial loss reputational dama e or data reaches
o Prevention Strategies: ethods and tools used to prevent or
reduce ris s related to the cy ercrime
c) Documentation and Analysis:
r ani e findin s in a document or presentation ith the follo in
sections
o Introduction: rief overvie of the assi ned cy ercrime
o Case Study: escription of a real orld e ample detailin the
incident and its impact
o Consequences: naly e ho the cy ercrime a ected the victims
and the roader implications
o Prevention: utline strate ies tools and est practices to avoid
fallin victim to this type of cy ercrime
d) Create a Report and Prevention Guide:
ompile the research into a concise report nclude visuals li e charts or
info raphics to sho trends in cy ercrime
repare a one pa e prevention uide summari in the ey prevention
tips for the specific cy ercrime his uide should e practical and easy
for classmates to understand
e) Presentation and Class Discussion:
ach roup ill present their findin s to the class e plainin the nature
of their assi ned cy ercrime its impact and e ective prevention
strate ies
fter each presentation the teacher ill facilitate a class discussion on
the roader importance of cy ersecurity and personal responsi ility
online
Result: fter the presentations students ill participate in a moderated discussion
Computer Science , Grade 9 183
led y the teacher to re ect on ey findin s from each roup s research his
discussion ill cover
Trends of cybercrime: servin patterns across di erent types of
cy ercrimes and identifyin hich crimes are most prevalent today
Impact on individuals and organizations: iscussin the social financial
and emotional toll cy ercrimes can ta e on victims
Effectiveness of prevention strategies: valuatin the practicality and
success of di erent prevention methods includin hich strate ies may e
most applica le in students o n di ital lives
Personal reflection on digital safety: ncoura in students to share ho the
research has shaped their understandin of cy ersecurity and hat actions
they mi ht ta e to improve their o n online safety
184 Computer Science , Grade 9
Unit 7 Concept of Programming
Figure 7.1
Let’s think!
a hat do you thin pro rammin is
hy do you thin pro rammin is important in today s orld
c efine al orithm
ust li e people use lan ua es li e epali e ari aithili ho puri n lish and
rench to tal to each other e use pro rammin lan ua es to communicate ith
computers hese lan ua es are hat computers understand ith pro rammin
lan ua es e can ma e all sorts of computer soft are verythin from operatin
systems li e indo s and inu to application soft are li e ce ac a e and
e ro sers is made usin pro rammin lan ua es
Fun Fact!
he first commercially availa le lan ua e as
ranslation developed in first manual appeared in ut first developed
in y a team led y ohn ac us at
Computer Science , Grade 9 185
7.1 Introduction to programming languages
pro rammin lan ua e is a lan ua e consistin of a set of instructions provided
y the user that tells a computer hat tas to do and ho to do it ython ava
etc are some e amples of popular pro rammin lan ua es
Programming: t is the process of providin
detailed instructions to a computer step y step to
do specific tas s
Programmer: pro rammer is a person ho is
involved in ritin computer pro rams
Syntax: he rule for ritin commands is called Figure 7.2
synta
Let’s check it!
hich is not a pro rammin lan ua e
a
c avad d ython
here are t o main types of pro rammin lan ua es hi h level and lo level
High-level programming language
a hese lan ua es use structures and commands that resem le human lan ua e
ma in them easier for people to understand
ro rams ritten in hi h level lan ua es are called pro ram code and they re
reada le to humans ut not to computers
Low-level programming language
a o level lan ua es mainly consist of s and s hich are directly understood
y computers
ro rams are ritten in the form of machine code hich is di cult for humans
to comprehend ithout speciali ed no led e
o ma e hi h level lan ua e pro rams understanda le to computers they need to
e converted into lo level pro rammin lan ua es his conversion is done usin
lan ua e translators li e interpreters and compilers
186 Computer Science , Grade 9
Programming tools: Flowchart and Algorithm
n al orithm is li e a recipe for computer pro rammin t s a step y step uide
that tells the computer e actly hat to do to solve a pro lem or computer tas
ust li e a recipe has instructions for ma in a dish an al orithm has instructions
for the computer to follo o chart is a dia ram that sho s the steps of an
al orithm in a visual ay t uses di erent shapes to represent di erent types of
actions and arro s to sho the direction of the process hin of it as a map that
uides you throu h the steps of the al orithms n al orithm and a o chart are
tools in pro rammin hey are helpful for uildin lo ic to solve pro lems efore
pro rammin
Algorithm
n al orithm is a set of step y step instructions desi ned to solve a specific
pro lem or perform a particular tas
t e ins ith start and ends ith stop
he instructions are ritten in simple eneral lan ua e li e spo en lan ua es
Flowchart
o chart is defined as the pictorial and raphical representation of an
al orithm
t utili es shapes oval rectan le parallelo ram etc to depict various
elements
he shapes have distinct meanin s in a o chart
he o charts correspond to al orithms visually representin their steps and
structure
The table below shows shapes used in flowchart and their meaning:
Name Shapes Meaning Uses
ar s the start and end points of
val tart nd
a o chart
andles input output ta in
arallelo ram nput utput
user input and displayin output
Computer Science , Grade 9 187
epresents processin or
ectan le rocessin
calculation steps in the o
irection of ho s the direction of o or
Arrow
o sequence in the o chart
ecision
hec s conditions and represents
iamond Condition
decision ma in points
hec
ct as a connector oinin
ircle Connector
components of the o chart
Example of algorithm and flowchart
ro lem o display the reater num er et een t o num ers
Algorithm: Flowchart:
Step 1: tart
Step 2: ead the first num er num
Step 3: ead the second num er num
Step 4: s num num
es isplay num is reater
o isplay num is reater
Step 5: top Figure 7.3
ere the pro lem is to find the reater num er et een t o num ers usin
pro rammin lo ic n order to solve the pro lem firstly the pro rammin lo ic is
ritten in terms of al orithm and visuali ed throu h the correspondin o chart
he lo ic involves
a ettin t o num ers num and num from the user
hec in if num is reater than num and ma in a decision on its asis
c isplayin the result is to the user
188 Computer Science , Grade 9
Activity 7.1
Activity Outcome -
le to list do n step and dra
Required Resources: hart apers eta ards ard oards ma e etc
Procedure:
reate an al orithm and o chart to illustrate the process of ma in tea
Result: ho the dra in to the teacher for further revie
Coding, testing and debugging
Coding: odin is the process of ritin instructions in a pro rammin
lan ua e to create soft are or applications hese instructions no n as code
tell the computer e actly hat tas s to perform
Testing: nce the code is ritten testin is conducted to ensure the pro ram
functions as e pected his involves runnin the pro ram to identify any errors
or u s and verifyin that all parts of the pro ram or correctly
Debugging: f testin reveals any errors or u s the process of de u in
e ins e u in involves locatin the source of the pro lem in the code
understandin hy it occurred and then ma in the necessary corrections to
fi it
hese three di erent steps are crucial for developin soft are that is relia le and
functions smoothly
Compiler and Interpreter
ma ine t o friends one spea s epali only and the other spea s ans rit only
hey ant to chat ut need someone ho understands oth lan ua es to translate
for them imilarly in computer pro rammin compilers and interpreters act as
translators for computers
Compiler
or a pro ram ritten in hi h level lan ua es e must convert it into its equivalent
machine lan ua e pro ram efore e can e ecute it on a computer e can convert
hi h level pro rammin lan ua es ith the help of a translator pro ram called
Computer Science , Grade 9 189
a compiler compiler is a translator of computer
pro rams that translate the entire hi h level lan ua e
into machine level pro rammin lan ua e in a sin le
operation on a computer ome of the most commonly
idely used compiled lan ua es are
etc
Some examples of compiler are:
a icrosoft visual studio
Figure 7.4
a compiler collection
a ommon usiness oriented lan ua es
Figure 7.5
Interpreter
ma ine you re tellin a friend ho to coo in a lan ua e they don t fully
understand ou d have to e plain each step one y one and they ould follo
your instructions steps y steps n interpreter or s similarly ith computer code
t ta es one instruction line of code translates it and then moves on to the other
line rather li e e plainin each step of the coo in process as your friend does it
his method can e slo er than havin all the instructions translated at once ut
it s useful ecause it can handle chan es more easily n interpreter is also more
porta le than a compiler as it is not
processor dependent you can or
et een hard are architectures he
most frequently used interpreted
lan ua e is t required less
memory
Figure 7.6
190 Computer Science , Grade 9
Some examples of interpreter are:
a ava cript
u y
c ist processin
d
e ython
ompiler and interpreter translate pro ram code into machine code hey
convert hi h level pro rammin lan ua e user friendly lan ua e into lo level
pro rammin lan ua e lan ua e understood y computers li e s and s hile
oth are lan ua e translators they or di erently
compiler translates the entire pro ram at once producin an e ecuta le file that
can run independently n interpreter on the other hand translates code line y
line as it e ecutes ithout creatin an independent file oth tools serve the same
purpose ena lin computers to understand and e ecute human ritten code
The table below shows the difference between compiler and interpreter.
Compiler Interpreter
compiler reads and translates n interpreter reads and translates pro ram
pro ram code to machine code all code to machine code line y line
at once
f there s an error in the pro ram f there is an error in the pro ram code it
code it displays errors at the end displays hile runnin the pro ram
ompiled pro ram s e ecution nterpreted pro ram s e ecution time is
time is comparatively faster comparatively slo er
ompiled pro rams have separate n interpreted pro ram does not have a
files to store machine code separate file to store machine code
Do you know?
n ssem ler is a special tool that translates pro rams ritten in ssem ly
lan ua e into machine code hich the computer can understand
Computer Science , Grade 9 191
Introduction to Python
ython a pro rammin lan ua e introduced y
uido van ossum in has ecome idely
popular due to its simplicity and versatility ith
ython e can solve a variety of pro lems and
even create our o n ames hat ma es ython
stand out is its easy to understand synta hich
is similar to everyday lan ua e his ma es it
particularly e inner friendly perfect for those ho
are ne to codin dditionally ython comes ith
a ealth of uilt in tools and li raries hese tools Figure 7.7
allo pro rammers to perform many di erent tas s ithout havin to start from
scratch each time his saves time and e ort ma in ython a po erful tool for
pro rammin tas s
ython is idely used in e development data science and machine learnin
artificial intelli ence data analysis automation and scriptin ame development
e scrapin cy er security etc
ython has a simple to understand codin style applyin indentation instead
of races to define loc s of code his unique feature increases reada ility y
supportin relia le indentation practices evelopers find ython s clear and
strai ht for ard synta easy to rite concise and understanda le or e ample in a
loop or conditional statement indentation si nifies the scope of the loc
Do you know?
he name of the ython pro rammin lan ua e comes from an old television
comedy s etch series called onty ython s lyin ircus
Features of Python
a. Easy to read and write
ython uses simple and understanda le synta ma in it easy for pro rammers
to rite and understand the code
b. Versatile
ython can e used for a ide ran e of tas s li e simple automatin systems to
comple e development data analysis and rtificial ntelli ence
192 Computer Science , Grade 9
c. Beginner-friendly
ython uses simple synta ma in it a reat choice for those ho are ne to
pro rammin
d. Extensive standard library
ython has an e tensive standard li rary of pre ritten code that o ers
pro rammers ready made solutions ithout requirin them to rite code from
round level
e. Rich ecosystem
ython has a vast collection of li raries and ready made structures no n as
frame or s that provide ready to use tools for pro rammers
Do you know?
ython is one of the fe pro rammin lan ua es reco ni ed y oo le as an
o cial lan ua e
Installation process of Python
Download python installer:
isit the o cial ython e site https ython or do nloads and do nload
the latest version of ython for indo s he e site ill automatically detect
your operatin system and o er the appropriate installer for your system it or
it
Download and install suitable IDE for Python.
Figure 7.8
Computer Science , Grade 9 193
Downloading python from official website
Run the installer:
ocate the do nloaded installer file usually in your o nloads folder and dou le
clic on it to run the installation process
Install Python:
elect your desired installation settin s clic on nstall to e in the installation
process his may ta e a fe minutes
Note: You can download python file by going through this link below:
[Link]
Comments in Python
n ython comments are rief messa es that pro rammers rite in their code to
e plain hat the code is doin li e leavin helpful hints for others to understand the
pro ram omments are indicated y the si n and the interpreter i nores them
treatin them as notes for the pro rammer hey don t a ect the actual pro ram
There are two types of comments in Python.
Single line Comment
n ython a short note or comment starts ith the sym ol and oes until the
end of that line f the note is lon er and needs more than one line each additional
line should also e in ith a sym ol here should not e hitespace after
Example 1:
his is an e ample of a sin le line comment
print epal has
Example 2:
his is an e ample of a in le line comment
his pro ram prints hat s special a out epal
print epal is a famous for
194 Computer Science , Grade 9
Multi-line comment
n ython hen a sin le line comment is not su cient and needs to o in multiple
lines it can e challen in to add a at the e innin of each line n such cases
ython allo s the use of triple sin le quotes at the e innin and end of the
comment to e tend it over multiple lines
Example:
his is an e ample to demonstrate the use of multiple line comments
his pro ram prints hat s special a out epal
print epal is home for various ethnic roups lan ua es and traditions
Keywords
In programming, keywords are reserved words that have predefined meanings
ey ords cannot e used as identifiers ome of the common ython ey ords are
listed elo
Let’s check!
hat are ey ords in ython
a ords used as comment in code dentifiers for varia les
c pecial ords reserved for specific purposes d ser defined functions
I/O statements and string formatting
n ython nput utput statements and strin formattin are essential for
interactin ith users and presentin information in a clear and ordered method
Input/Output statements (I/O)
statements help us to interact ith the pro ram hey allo us to provide our
data and instructions to the pro ram as ell as display the output on screen n
ython the statement used to ive data and instruction to the pro ram is an input
statement and the statement to display the output on screen is print
Computer Science , Grade 9 195
1. Print Statement
he print statement in ython
is used to display information
on the screen e use a print
statement to display the output
of data that e ant to sho
Figure 7.9
Example: print ello ython
2. Input Function
he input function allo s us to
provide input to the pro ram
e can ive data to the pro ram
as e need
Example: num er input nter
num er String Formatting
trin formattin in ython is
li e creatin a special messa e Figure 7.10
here you fill in the lan s ith the information you ant t involves usin a
messa e template allo in you to insert di erent names or num ers at specific
spots to ma e your messa es more interestin and customi ed
1. Old-style formatting
n earlier times e used to insert values into a strin his as the old
ay of formattin the strin values
name am
a e
print y name is s and
am d years old name a e
utput my name is am and
am years old
Figure 7.11
196 Computer Science , Grade 9
2. New-style formatting ([Link])
he ne style strin format uses placeholders and the format
method t is used in ne er enerations of formattin
name ita
a e
print y name is and am
years old format name a e
Output: y name is ita and am
years old Figure 7.12
3. Formatted string literals
his is the most idely used method in strin formattin in the current
time n formatted strin literal e use f efore the strin and em eddin
e pressions inside t is the most popular method of usin strin format
ormatted trin iterals f strin s
name hiva
a e
print f y name is name
and am a e years old
Output: y name is hiva
and am years old Figure 7.13
Data types and variables
ma ine you have a collection of di erent types of fruits in your itchen ach
fruit has its o n unique characteristics such as color taste and si e n computer
pro rammin data types are li e the di erent types of fruits ust as you sort fruits
in cate ories li e apples oran es and ananas pro rammers use data types to
or ani e and cate ori e di erent inds of information ur data can e in various
forms li e num ers decimals alpha ets or special characters
Computer Science , Grade 9 197
The classification of data based on its nature is called datatype. ython also
o ers various data type hich are listed as
Integer (int): t is a hole num er ran in from ne ative infinity to positive infinity
Examples:
Float (float): t is num ers ith decimals
Examples:
String (str): t consists of alpha ets special characters alphanumeric values hich
are enclosed in dou le quotes
Examples: hello ython ahendrana ar athmandu
Boolean (bool): t only provides rue or alse values
Example: is student rue has mo ile alse
Identifier
dentifiers are names iven to pro ram units such as varia les functions classes or
other entities hey are not predefined in the pro rammin lan ua e ut are defined
y pro rammers themselves
Rules for identifier
i n identifier name must start ith a letter or the underscore character
ii n identifier name cannot start ith a num er
iii n identifier name can only contain alpha numeric characters and underscores
and
iv ython is case sensitive so identifier names are also case sensitive a e e
and are three di erent identifiers
v n identifier name cannot e any of the ython ey ords
Valid identifiers
irst ame
Invalid identifiers
int print first name def
198 Computer Science , Grade 9
Variables
aria les are li e containers that hold information ma ine you have la elled
o es here you can eep di erent types of items hose o es contain di erent
cate ories of item and you have la elled them accordin ly aria les are similar to
these o es as they hold di erent types of data
ython doesn t have any command for declarin a varia le varia le is created
hen the value is assi ned to it
Example:
et s consider the e ample of data type and varia le ith the e ample iven elo
Variables Description
a e ‘age’ is the varia le name of the inte er data type and it holds the
inte er value n ython it is represented as
age=15
ei ht ‘height’ is the varia le name of the oat data type and it holds the
oat value n ython it is represented as
height=5.7
Fname ‘fname’ is the varia le name of the strin data type and it holds the
strin value an o n ython it is represented as
fname=“Sanjog”
is_student is_student is the varia le name of the oolean data type and it
holds the oolean value rue n ython it is represented as
is_student = True.
Concept of Type Casting
ma ine you re developin a pro ram for a a ery here customers can place
orders for ca es ou receive orders in the form of strin s ut you need to convert
them into numerical values inte ers or oats to perform calculations and mana e
inventory ype castin is the process of convertin a varia le from one data type
to another n this process the compiler automatically ad usts the data type ased
Computer Science , Grade 9 199
on the pro ram s requirements or e ample if e assi n an inte er int value
to a oat varia le the compiler ill convert the int value to a oat ype castin
allo s pro rammers to e plicitly control these conversions ensurin the computer
understands the ind of data needed for specific tas s
There are two types of casting: Implicit casting and explicit casting.
Implicit casting
mplicit type castin also no n as automatic type conversion occurs hen
the ython interpreter automatically converts one data type to another in certain
situations
Examples:
inte er
y oat
y the inte er is cast to a oat for the addition
print(z)
Explicit casting
n e plicit type castin the user intentionally converts the data type of a varia le to
another data type ollo in are the approaches of castin the data type intentionally
Figure 7.13
200 Computer Science , Grade 9
1. int(x): onverts to an inte er
int(x) cast to int
print(x)
2. float(x): onverts to a oatin point num er
float(x) cast to oat
print(x)
3. str(x): onverts to a strin
str(x) cast to strin
print(x)
Operators and Expressions: Arithmetic, Relational, Logical,
Assignment
perators are special sym ols that e use to do di erent thin s ith num ers
and ords hich allo s us to perform specific actions hey are li e tools in our
pro rammin tool o that help us to or ith information
Some of the operator types are described below:
1. Arithmetic operator
rithmetic operator is used in ython to do mathematical operations e use
arithmetic operators as special sym ols to do asic math t is li e havin a set
of tools for simple calculation
Using arithmetic operators in Python:
Operators Description Example
t is used for addition print
- t is used for su traction print(7 - 2)
* t is used for multiplication print(4 * 6)
/ t is used for division print(10 / 2)
t is used for modulus print
** t is used for e ponentials print(3 ** 2)
Computer Science , Grade 9 201
Simple program to find the sum of the two number for the user input
num oat input nter first num er
num oat input nter second num er
sum num num
print he sum of and is format num num sum
Activity 7.2
Activity Outcome -
le to rite a appropriate pro ram
Procedure:
rite a simple code to print ello lass y name is our ame hen
comment in every step of code usin sin le line comment and multi line comment
to e plain the purpose of the pro ram and ho it or s
Result: complete pro ram
2. Relational operator
elational operator is used to chec and compare values hese operators
chec the relationship et een t o thin s and tell us if they are equal reater
than or less than each other
Here are the main relational operators:
Name Operator Description Example
qual to o thin s are e actly the same
ot equal to o thin s are not the same
reater than ne is reater than the other
(separate)
Less than ne is less than the other
reater than or s reater or equal to another
equal to
Less than or s less or equal to another
equal to
202 Computer Science , Grade 9
3. Logical operator
o ical operators in ython are used to com ine conditions and ma e decisions
ased on di erent situations his operator is li e a tool that helps us ma e
decisions ased on di erent situations here are main lo ical operators
and or and not
AND:
oth the conditions must e true for the result to e true in the and operator
ample and
esult alse
Truth table for ‘AND’ operators
A B A and B
0 0 0
0 1 0
1 0 0
1 1 1
OR:
nly one of the conditions needs to e true for the result to e true in the or
operator
ample or
esult rue
Truth table for ‘OR’ operators
A B A and B
0 0 0
0 1 1
1 0 1
1 1 1
NOT:
he lo ical operator not provides the opposite result of a iven condition
Computer Science , Grade 9 203
Example: not
Result: rue
Truth table for ‘NOT’ operators
A
0 1
1 0
4. Assignment operator
Operator Name Example
ssi nment perator a
ddition ssi nment a a a
u traction ssi nment a a a
ultiplication ssi nment a a a
ivision ssi nment a a a
emainder ssi nment a a a
ponent ssi nment a a a
uppose e put in redients li e salt su ar spices and turmeric in di erent
containers o no hat is there inside the particular container e put
la els outside the containers
Assignment operators are used to assign values to variables.
sin the assi nment operator
Example
assi n to a
a
assi n to
assi n the sum of a and to a
a a a
print(a)
204 Computer Science , Grade 9
Output: 15
Example:
n this e ample my a e is assi ned the value ere my a e is li e a o and
the assi nment operator is puttin the value inside that o o henever
you use my a e in your pro ram it s li e openin the o and findin the num er
o the assi nment operator is li e a la ellin machine in ython that helps us eep
thin s or anised y ivin names to data
Expressions
n e pression in ython is li e a formula that tells the computer to do somethin
ith num ers and ords t is li e a command that produces a value hey are li e
the uildin loc s of our code tellin the computer hat to do ith the information
e provide
Here, are some examples of expressions:
Maths expression: result
Text expression: reetin ello
Combining expression: com ined ython
Algebraic expression Python expression
a a a a
Operands
n pro rammin operands are values or varia les that operators operate on
perands refer to the values or entities that are operated upon y an operator hey
are the varia les that utili e the operators
Example: add = 5 + 3
ere and are operands and is an operator and it is performin an addition
operation
Computer Science , Grade 9 205
Let’s check
n the ython statement a a and are
a erm perators c perands d quation
Conditional statement
conditional statement is li e a decision ma in tool that helps our pro ram choose
hat to do ased on conditions provided y the user e can as a question and
provide di erent ans ers ased on the conditions provided he most fundamental
form of conditional statement is if statement, “if - else” statement and “if - elif -
else statement
he statement to e e ecuted follo s the indentation rule of ython
if statement
if statement is a conditional statement that ives us output ased on the requirement
of the condition that e provide if statement is ritten usin the if ey ord and
after that condition is provided and ends ith indentation
Syntax
if condition
statement to e e ecuted hen the condition is true
Flowchart:
Figure 7.14
206 Computer Science , Grade 9
Example:
if statement pro ram to chec if a num er is positive
num er int input nter a num er
if num er
print he num er is positive
Figure 7.15
if-else condition
Syntax
if condition
statement to e e ecuted hen the condition is true
else:
statement to e e ecuted hen the condition is false
Flowchart:
Figure 7.16
Computer Science , Grade 9 207
Example:
s in a e to the user and providin results
user a e int(input o old are you
if user a e
print ou are an adult
else:
print ou are a teena er or a id
Figure 7.17
if-elif-else condition
Syntax
if condition
code to e e ecuted if condition is rue
elif condition
code to e e ecuted if condition is rue
else:
code to e e ecuted hen condition and condition are alse
Flowchart:
Figure 7.18
208 Computer Science , Grade 9
Example
hec in the num er s cate ory hether it is positive ne ative or ero
user num er int(input nter a num er
if user num er
print he num er is positive
elif user num er
print he num er is ero
else:
Figure 7.19
print he num er is ne ative
Nested if (if inside if)
Nested if statement is a construct where we put another if statement inside an
e istin if statement t is used to test multiple criteria and increase the num er of
possi le outcomes t helps in decision ma in usin multiple conditions
Syntax:
if condition
code to e e ecuted if condition is rue
if condition
code to e e ecuted if condition is rue
else:
code to e e ecuted hen condition is alse
else:
code to e e ecuted hen condition and condition are alse
Computer Science , Grade 9 209
Flowchart:
Figure 7.20
Example:
a e int input nter your a e
if a e
print ou are eli i le for citi enship
if a e
print ou are eli i le to cast a vote
else:
print ou are not eli i le to cast vote Figure 7.21
else:
print ou are a minor
Iteration
teration means doin thin s repeatedly teration is the process of repeatin a
particular tas until a specified condition is satisfied t allo s a pro ram to perform
a tas multiple times until a required condition is satisfied teration is li e havin
a helper that repeats tas s for you ma in your pro ram more e cient and savin
210 Computer Science , Grade 9
you from ritin the same thin repeatedly he most fundamental e ample of
iteration is the for loop and hile loop
Do you know?
he first instance of loop as used y da ovelace to
calculate ernoulli num ers da ovelace a ondon orn
mathematician is also referred to as the first pro rammer in
the orld
Figure 7.21
For loop
or loop is used hen e no ho many times e ant to repeat a loc of
code for loop in ython is a control o structure that allo s us to iterate over
a sequence t simplifies the process of repeatedly e ecutin a set of statements for
each time in the sequence he asic idea is to loop throu h each element in the
sequence e ecutin a loc of code for each iteration he for loop is particularly
useful hen the num er of iterations is no n
“for ey ord is used in the for loop to ive the condition
Syntax:
for item in sequence
ode to do somethin ith each item
sin for loop to print ump five times
for in range
print ump
Figure 7.23
Computer Science , Grade 9 211
n ython ran e is a function that helps you ma e a list of num ers in a certain
order t returns a sequence of num ers startin from y default and increments
from y default and stops efore a iven num er y user
Pass
n ython the pass ey ord is a null operation or a no operation statement t acts
as a placeholder here some code is required ut no action is necessary t is often
used hen a statement is required y ython synta ut you don t ant to e ecute
any code
Example:
if condition
ome code here
else
pass othin happens in the else case
Continue
n ython the continue ey ord is used in loops such as for or hile loops t is
used to s ip the rest of the code inside the loop for the current iteration and move
on to the ne t iteration t allo s us to ypass certain parts of the loop ased on a
condition ithout e itin the loop entirely
Example:
for num er in ran e
if num er
continue ip the rest of the loop for num er
print(number)
Break
n ython the rea ey ord is used in loops such as for or hile loops to e it
the loop early even if the loop s condition hasn t een fully satisfied t allo s us to
terminate the loop ased on a certain condition
212 Computer Science , Grade 9
Example:
for num er in ran e
if num er
rea it the loop hen num er is
print(number)
While loop
hile loop in ython is a control structure that allo s us to repeatedly e ecute
a loc of code as lon as certain conditions remain true It’s like having a set of
instructions for a computer to keep doing something over and over until a specific
goal is achieved or a condition is no longer met. t provides a e i le ay to handle
tas s here the num er of iterations is not no n in advance
Syntax
while condition:
ode to e e ecuted hile the condition is true
his code is indented and forms the ody of the loop
t continues e ecutin as lon as the condition remains true
emem er to update the condition to eventually ecome false or you mi ht
end up ith an infinite loop
sin hile loop to print num ers from to
count
hile count
print(count)
count
Figure 7.24
Computer Science , Grade 9 213
Difference between for loop and while loop.
For loop While loop
or loop is used hen e no the hile loop is used hen e don t no
num er of iterations the num er of iterations
his loop iterates an infinite num er of f the condition is not specified it sho s
times if the condition is not specified compilation error
he increment is done after the he increment can e done efore or
e ecution of the statement after the e ecution of a statement
he nature of increment is simple he nature of increment is comple
nitialisation can e in or out of the loop nitialisation is al ays out of the loop
Let’s check!
hich loop is used hen the num er of iterations is no n eforehand
a or loop hile loop c o hile loop d one of the a ove
Python list
ython list is one of the uilt in data types in ython used to store multiple data in
a sin le varia le list can contain hetero eneous types of elements hich means
elements can have di erent data types li e inte ers strin s oats ooleans etc
ist elements are enclosed y square rac ets and elements are separated y comma
Example:
thislist omputer cience rue
print thislist
Figure 7.25
Let’s know more!
n ython lists support a rich set of operations that are common to all sequence
types includin tuples strin s and ran es hese operations are no n as
common sequence operations
214 Computer Science , Grade 9
Features of Python list
ist elements are inde ed he inde al ays e ins from o the first list element
al ays has inde so as the second list element has inde and so on
ote he inde helps to access the list elements
Example:
thislist omputer cience rue
print thislist
Figure 7.26
he output is ecause the element associated ith inde is
ist can have duplicate elements
Example:
thislist omputer cience
rue omputer
print thislist
Figure 7.27
ists are ordered f e add ne elements in the list the ne element ill hold the
last position of the list o add an element to the list e use the append method
hich is oined usin operator ith the list varia le
Example:
thislist omputer cience rue
thislist append ocial add ne
element in list
print thislist Figure 7.28
o remove elements from list del ey ord is used precedin the list varia le
specifyin the list inde
Computer Science , Grade 9 215
Example:
thislist omputer cience
rue ocial
del thislist removes the element
from list
print thislist Figure 7.29
List length
o find the num ers of elements present in the list e use len function he len
function ives us the num er of list elements present in the list
Example:
thislist omputer cience rue
a len thislist
print(a)
Figure 7.30
Looping through list
e can loop throu h the list elements usin the for loop to print all the elements
one y one
Example:
thislist omputer cience rue
for in thislist
print
Figure 7.31
216 Computer Science , Grade 9
Activity 7.3
Activity Outcome -
le to rite a appropriate pro ram
Required Resources: to insert another fruit rape in the list
Procedure:
rite a pro ram to add ne items in the list
Result: a complete pro ram
Python Dictionary
icture a real life dictionary here you loo up ords to find their meanin s n
ython a dictionary is li e that ut instead of ords and meanin s it stores pairs
of eys and values hin of eys as the ords and values as their meanin s he
ey value pairs are stored to ether so that you can quic ly loo up a ey and et its
correspondin value
n ython dictionaries are used to store data in Key:Value pair
dictionary is a collection of data in ey alue pairs ritten ithin curly races
Example:
Key:value pairs are ritten ithin the curly races ere
he student is ey and value associated to it is pen
he teacher is ey and value associated to it is mar er
he tailor is ey and value associated to it is needle
n this ay e can add as many ey value pairs as e ant
Note: he values in the dictionary can e of any data type
Computer Science , Grade 9 217
Example:
mydict
student pen
teacher mar er
tailor needle
mar s
is present rue
Figure 7.32
print(mydict)
Features of dictionary
uplicate eys are not allo ed n the ython dictionary t o values ith the same
ey cannot e ist f the same ey has t o or more values the ne value ill replace
the old value
Example:
mydict
student pen
teacher mar er
tailor needle
mar s
is present rue
teacher duster
Figure 7.33
print(mydict)
he older value mar er of ey teacher ets replaced y duster
218 Computer Science , Grade 9
Dictionaries are changeable:
fter the dictionary has een created e can add or remove values ne value is
added to the dictionary usin a ne ey inde and value associated ith it
Example:
mydict
student pen
teacher mar er
tailor needle
mar s
is present rue Figure 7.34
mydict mechanic tools
print(mydict)
he del ey ord is used to remove specified ey names in the dictionary
Example:
mydict
student pen
teacher mar er
tailor needle
mar s
is present rue
mechanic tools
Figure 7.35
del mydict mechanic
print(mydict)
Computer Science , Grade 9 219
Accessing the value in dictionary
he value in the dictionary can e accessed y referrin to its ey name y placin
the ey name inside a square rac et
Example:
mydict
student pen
teacher mar er
tailor needle
mar s
is present rue
a mydict teacher
print(a)
Figure 7.36
Dictionary length
o determine the num ers of ey values present in the dictionary len function is
used
Example:
mydict
student pen
teacher mar er
tailor needle
mar s
is present rue
Figure 7.37
len mydict
print(b)
220 Computer Science , Grade 9
Looping through Dictionary
e can loop throu h the dictionary usin the for loop to print all the elements one
y one
Example:
mydict
student pen
teacher mar er
tailor needle
mar s
is present rue
for in mydict
print Figure 7.38
Difference between list and dictionary
List Dictionary
list stores elements in a dictionary stores data in ey value pairs
sequence
ist elements are accessed y ictionary values are accessed y eys
inde
ist elements have an order ictionary values don t have any specific order
ist elements can e added and ictionary values are added as ey value pair
removed and removed y ey
Computer Science , Grade 9 221
Uses of Library functions
String functions
collection of related assertions that carry out a mathematical analytical or
evaluative operation is no n as a function n assortment of proclamations called
ython apa ilities returns the specific errand unction names meet the same
standards as varia le names do he o ective is to define a function and roup
specific frequently performed actions ython includes the follo in some uilt in
methods to manipulate strin s
center()
he center() method returns a strin hich is padded ith the specified character
syntax
strin center idth fillchar
center() Parameters
he center method ta es t o ar uments
width len th of the strin ith padded characters
fillchar optional paddin character
he fillchar ar ument is optional f it s not provided space is ta en as the default
ar ument
Example: center ethod ith efault fillchar
strin ython is a esome
222 Computer Science , Grade 9
ne strin strin center
print entered trin ne strin
Output
Centered String: Python is awesome.
upper()
ython strin method upper() returns a copy of the strin in hich all case ased
characters have een uppercased
Syntax: str upper
Example:
str this is a strin e ample o
print str upper
Output:
lower()
ython strin method lower() returns a copy of the strin in hich all case ased
characters have een lo ercased
Syntax: str lo er
Example:
str
print str lo er
Output:
his is a stron e ample o
len()
Computer Science , Grade 9 223
ython strin method len() returns the len th of the strin
Syntax: len str
Example:
str this is strin e ample o
print en th of the strin len str
Output:
en th of the strin
Numeric and mathematical functions
n python a math module is used to access mathematical functions ll methods
of math function are used for inte er or real type o ects ut not for comple
num ers
Numeric functions: ome of the uilt in numeric functions are
sum ums the items of an itera le
total sum
output:
total is
a s eturns the a solute value of a num er
a solute a s
output:
a solute is
round() ounds a num er to a specified num er of decimal places
rounded round
output:
rounded is
224 Computer Science , Grade 9
max() and min() eturn the lar est and smallest items in an itera le or the lar est
smallest of t o or more ar uments
ma imum ma
output:
ma imum is
minimum min
output:
minimum is 1
Mathematical functions
[Link](): eturns the square root of a num er
import math
root math sqrt
output:
root is
[Link]() and [Link](): eturn the ceilin or oor of a num er
ceiling = [Link](3.14)
output:
ceilin is
oor math oor
output:
oor is
[Link](): eturns the factorial of a num er
factorial math factorial
output:
factorial is
Computer Science , Grade 9 225
[Link](): eturns a num er raised to the po er of another num er
po er math po
output:
po er is
[Link](), [Link](), [Link]() eturn the sine cosine and tan ent of a
num er in radians
sine math sin math pi
output:
sine is
cosine math cos
output:
cosine is
tan ent math tan math pi
output:
tan ent is
[Link](): eturns the natural lo arithm of a num er
natural lo math lo
output:
natural lo is
Practice Tasks
1. Adding two numbers (Constant variable initialization)
num er
num er
add num er num er
print he addition of num er and num er is add
226 Computer Science , Grade 9
2. Adding two numbers asking from the user
num er int input nter the first num er
num er int input nter the second num er
result num er num er
print f he sum of num er and num er is result
3. Calculating the area of a circle int pi radius
radius oat input nter the radius of the circle
area radius sin formula
print he area of the circle is area
1. Calculating the area of the rectangle
len th oat input nter the len th of the rectan le
idth oat input nter the idth of the rectan le
area len th idth sin formula
print he area of the rectan le is area
5. Printing the name of user by asking name (string formatting)
user name input nter your name
reetin f ello user name
print reetin
6. A program that takes current temperature as input and displays “it’s a
warm day” if it’s above 25.
temperature oat input nter the current temperature in elsius
if temperature
print t s a arm day
7. A program that shows odd or even numbers using an if statement
num er int input nter an inte er
if num er
print he num er is even
Computer Science , Grade 9 227
if num er
print he num er is odd
8. Finding the greatest between two numbers asking from the user
num er input nter the first num er
num er input nter the second num er
if num er num er
reater num er num er
else
reater num er num er
print he reater num er is reater num er
9. A program to check whether the given number is inside range (10 -100) or not
num er oat input nter a num er
if num er
print he num er is ithin the ran e
else
print he num er is outside the ran e
10. A program to check whether the number is divisible by 7 or not
num er int input nter a num er
if num er
print f num er is divisi le y
else
print f num er is not divisi le y
11. Finding the greatest between three numbers asking from the user
num er int input nter the first num er
num er int input nter the second num er
num er int input nter the third num er
228 Computer Science , Grade 9
if num er num er and num er num er
print num er is reater num er
elif num er num er and num er num er
print num er is reater num er
else
print num er is reater num er
12. A program to check whether year is leap year or not
year int input nter the year
if year
if year
print ntered year is a leap year
else
print ntered year is not a leap year
else
if year
print ntered year is a leap year
else
print ntered year is not a leap year
13. A program to find the middle number among three numbers
num oat input nter the first num er
num oat input nter the second num er
num oat input nter the third num er
if num num num or num num num
middle num er num
elif num num num or num num num
middle num er num
else
Computer Science , Grade 9 229
middle num er num
print f he middle num er amon num num and num is middle
num er
14. A program that takes students’ scores as input and provides grades based
on certain criteria
score oat input nter the student s score
if score
rade
elif score
rade
elif score
rade
elif score
rade
else
rade
print f he student s rade is rade
15. A program to classify triangle based on angles
an le oat input nter the first an le
an le oat input nter the second an le
an le oat input nter the third an le
if an le an le an le
if an le an le an le
print t s an quilateral trian le
elif an le an le or an le an le or an le an le
print t s an sosceles trian le
else
print t s a calene trian le
230 Computer Science , Grade 9
else
print nvalid trian le an les
16 . A program to print numbers from 1 to 10 using a for loop
for num er in ran e
print(number)
17. A program to print the sum of the first 10 natural numbers using a for loop
sum of num ers
for num er in ran e
sum of num ers num er
print he sum of the first natural num ers is sum of num ers
sum of num ers
for num er in ran e
sum of num ers sum of num ers num er
print he sum of the first natural num ers is sum of num ers
18. A program to print even numbers in a range
ran e the no at end tells pro ram to s ip num er y
for i in ran e
print(i)
19. A program to print numbers (10-1) in reverse order
ran e the no at end tells pro ram to count num ers in reverse
order)
for i in ran e
print(i)
Computer Science , Grade 9 231
20. A program to print factorials of 10
num
factorial
for i in range num
factorial i
print f actorial of num factorial
21. A program to print star pattern as shown in the figure for i in range (1, 6):
ro ram to print star pattern
for i in ran e
rint i
22. A program to calculate average of given numbers
num ers
total sum num ers
avera e total len num ers len ey ord ives total len th of
numbers
print vera e avera e
23. A program to find the sum of N numbers
int input nter the value of
total
for i in ran e
num oat input f nter num er i
total num
print f he sum of num ers is total
24. A program to print numbers from 1 to 15 using a while loop
num er
hile num er
print(number)
num er
232 Computer Science , Grade 9
25. A program to print the first 10 integers and their squares using a while
loop
i
hile i
square i
print f um er i quare square
i
26. A program to print the sum of the first 10 natural numbers using a while
loop
sum of num ers
num er
hile num er
sum of num ers num er
num er
print he sum of the first natural num ers is sum of num ers
27. A program to print products of digits of numbers accepted from users
num er int input nter a num er
product
hile num er
di it num er
product di it
num er
print roduct of the di its product
28. A program to reverse the number from user using while loop
num er int input nter a num er
reversed num er
hile num er
di it num er
Computer Science , Grade 9 233
reversed num er reversed num er di it
num er
print eversed num er reversed num er
29. A program to print Fibonacci series till n terms provided by the user
i onacci series e ins ith and fter that each num er is o tained y
addin the t o previous num ers to ether
ach term in the series is o tained y addin the t o previous terms or
e ample and so on
0, 1, 1, 2, 3, 5, 8, 13
n int input nter the num er of terms in the i onacci series
first term
second term
count
hile count n
print first term end
ne t term first term second term
first term second term
second term ne t term
count
30. A program to check if a number is an Armstrong number using a while
loop (Armstrong number is a number that is equal to the sum of cubes of
its digits.
13 3 3
)
num er int input nter a num er
ori inal num er num er
234 Computer Science , Grade 9
num di its len str num er
sum of di its
hile num er
di it num er
sum of di its di it num di its
num er
if ori inal num er sum of di its
print f ori inal num er is an rmstron num er
else
print f ori inal num er is not an rmstron num er
Practical Task
o nload ython to your computer and install it
Exercises
1. Answer these questions.
a plain pro rammin lan ua es ith its types
i erentiate et een compiler and interpreter
c efine al orithm and o chart
d rite five sym ols ith their functions of o chart
e reate an al orithm to find hether the iven num er is odd or even lso
ma e o chart from the al orithm
f plain ython pro rammin ith its features
escri e the use of input output statements in ython
h efine formatted strin literals emonstrate its use in a simple pro ram
here the user inputs their name and the output is displayed ello user
name elcome to our pro ram
Computer Science , Grade 9 235
i plain the data types ith e amples
escri e typecastin ith its types
ist the types of operators plain any one of them in detail ith
e amples
l plain a conditional statement ith an e ample
m efine iteration i erentiate for and hile loop
n i erentiate et een list and dictionary
o iven is the list elements
athmandu iratna ar epal un o hara ut al irendrana ar
ahendrana ar alefi
a dd list item alan a a
emove list item alefi
c rint the list items one y one usin a loop
2. Write the names of technical terms:
a set of instructions to perform a specific tas
he set of rules to rite a pro ram
c an ua e translator that reads and translates pro ram code to machine
code line y line
d he raphical or pictorial representation of a pro ram
e e t added in source code for the purpose of providin information or
e planation that is i nored y the ython interpreter durin e ecution
f data type that only provides true or false value
special sym ol that is used to chec the relationship et een t o
varia les
h he values or entities that operators act upon in pro rammin
i decision ma in control structure that helps our pro ram to choose
what to do
he process of repeatin a tas until a specified condition is met
236 Computer Science , Grade 9
3. Write true or false for the following statements.
a ro rammin lan ua e is used to ive commands to the computer
omputers understand hi h level pro rammin easily
c ompiler and interpreter translate pro rammin code to machine code
d l orithms are a raphical representation of instructions
e ython is a machine understanda le pro rammin lan ua e
f rint statement is used to display output in ython
n ython int data type denotes alpha etical characters such as hello
h ype castin is the conversion of one data type to another
i n operator all the conditions must e true for the result to e true
n ython if statement is used to provide a condition that hen false
allo s a loc of code to e e ecuted
for loop in ython is used to repeat a process until a specified time iven
y the user
l ictionaries have ey value pairs
m ist items cannot e chan ed
n n the dictionary the data can e deleted y value
4. Write full forms of the following.
i ii
iii iv
5. Choose the correct answer.
a n the conte t of pro rammin lan ua e hat does the term synta
refer to?
i he meanin of the code
(ii) A set of instructions
iii ciency of code e ecution
iv tructure and rules of code
Computer Science , Grade 9 237
computer understands
i hi h level pro rammin lan ua e
ii lo level pro rammin lan ua e
iii natural human lan ua e
iv sym ols and pictures
c o does a o chart represent a process in a pro ram
i t provides a set of instructions for the computer
ii t visually sho s the steps and decision points in a process
iii t directly e ecutes the al orithm on the computer
iv t is a hi h level pro rammin lan ua e
d o does an al orithm di er from o chart
i l orithm is visual hile a o chart is te tual representation
ii n al orithm and o chart are interchan ea le terms
iii l orithm is pro rammin lan ua e hile o chart is a stract
concept
iv l orithm is a step y step procedure hile o chart is a
pro rammin lan ua e
e ython is a pro rammin lan ua e
i natural ii lo level
iii hi h level iv easy
f hat are ey ords in ython
(i) Words used as comment in code
ii dentifiers for varia les
iii pecial ords reserved for specific purpose
iv ser defined functions
238 Computer Science , Grade 9
nput function is used in ython to
(i) retrieve user input
ii display the information
iii define varia le
iv perform mathematical calculation
h hat data type in ython is suita le for representin te t and characters
i loat ii oolean
iii nt iv trin
i hat ill e the result of the follo in e pression oat
i ii iii iv rror
hat is the function of the operator in ython
i hec for equality ii ive rue value
iii onvert e pression to strin iv e ate oolean e pression
hat does the iven ima e represent
i t is a o chart tellin us to rin um rella
ii t is a o chart ivin us information a out rain
iii t is a o chart sho in decision to ma e ased
on the condition of rain
iv t is a o chart tellin us not to rin um rella
o are elements accessed in a ython list
i y eys ii y values
iii y indices iv y attri utes
Computer Science , Grade 9 239
hich of the follo in statements accurately descri es the muta ility of
ython lists and dictionaries
i ists are immuta le hile dictionaries are muta le
ii oth lists and dictionaries are immuta le
iii oth lists and dictionaries are muta le
iv ists are muta le hile dictionaries are immuta le
hat is the primary purpose of ython lists
i torin data in ey value pairs
ii torin data in a sequence
iii torin data in a unordered manner
iv ssociatin eys ith values
6. Practise these practical questions.
Input/Output
a rite a pro ram to as input as name from the user and reet the user
as he she provides their name
rite a pro ram to input sides of trian le and print area
c rite a pro ram to input a radius and find the area of circumference of
circle
d rite a pro ram to input di its as inte ers and calculate their sum and
avera e
e rite a pro ram to input a diameter and print area of circle and
circumference of circle
Constant value and Operators
a rite a pro ram to input a radius and find the area of circumference of the
circle
240 Computer Science , Grade 9
rite a pro ram to sho the use of arithmetic operators erform add
su tract multiply divide square and modulus et een t o num ers
c rite a pro ram to sho the use of a comparison operator et een t o
varia les se the follo in operators
If…..else Statement
a rite a pro ram usin the if statement to chec hether the iven num er
is positive
rite a pro ram that ta es people s a e as input and chec s hether they
are eli i le to vote otin a e is and a ove
c rite a pro ram to chec hether the iven num er is even or odd usin
an if else statement
d rite a pro ram to input t o num ers and find the smallest num er
e rite a pro ram that ta es students mar s as an input and chec s hether
the student passed or failed or reater is pass mar s
f rite a pro ram that ta es num ers as inputs and displays the smallest
num er
a e a pro ram li e a tra c li ht usin an if elif else statement s
input from the user on providin color reen o red stop and oran e e
ready any other color invalid color
h rite a pro ram to input practical and theory mar s of omputer and
chec pass or fail ou can also validate hether a user has entered valid
mar s or not valid mar s should e chec ed for oth theory and practical
For loop
a rite a pro ram to print num ers from
rite a pro ram to print an input name times
c rite a pro ram to print the squares of num ers from to usin a for
loop
Computer Science , Grade 9 241
d rite a pro ram to print first odd num ers
e rite a pro ram that ta es an inte er as input and prints the multiplication
ta le for that num er
While loop
a rite a pro ram to print num ers from
rite a pro ram to print first even num ers
c rite a pro ram to calculate the factorial of a iven num er
d rite a pro ram to print the sum of the first odd num ers
e rite a pro ram to input multi di its num ers and display the sum of the
di its
Lists
rite a ython pro ram to create a list of inte ers and print the list
rite a ython pro ram to print the second and fourth elements of a list
rite a ython pro ram to append a ne element to the end of a list and
print the updated list
rite a ython pro ram to print the first three elements of a list usin
slicin
rite a ython pro ram to print the len th of a list
rite a ython pro ram to iterate throu h a list and print each element
rite a ython pro ram to create a list of squares of num ers from to
usin list comprehension
rite a ython pro ram to remove the third element from a list and print
the updated list
Dictionaries
rite a ython pro ram to create a dictionary ith ey value pairs and
242 Computer Science , Grade 9
print the dictionary
rite a ython pro ram to print the value associated ith a specific ey
in a dictionary
rite a ython pro ram to add a ne ey value pair to a dictionary and
print the updated dictionary
rite a ython pro ram to remove a ey value pair from a dictionary
usin the del statement and print the updated dictionary
rite a ython pro ram to iterate throu h a dictionary and print all the
eys
rite a ython pro ram to create a dictionary here the eys are num ers
from to and the values are their squares usin dictionary comprehension
rite a ython pro ram to chec if a specific ey e ists in a dictionary
rite a ython pro ram to mer e t o dictionaries and print the resultin
dictionary
Project Work
evelop a money e chan e system in ython and rite a report on it our pro ect
should include functionalities for convertin et een various currencies usin
e chan e rates
Steps to Follow:
Understand the Requirements:
esearch and decide on the features to include such as currency conversion
displayin e chan e rates and handlin errors
dentify the currencies to support e
Design the Program:
utline the structure of your pro ram usin pseudocode or a o chart
nclude functions for ey features li e fetchin e chan e rates convertin
currencies and displayin results
Computer Science , Grade 9 243
Write the Code:
evelop the pro ram in ython ensurin proper use of functions loops and
conditionals
r ani e the code into lo ical sections ith meanin ful varia le and function
names
dd comments for clarity
Test the Program:
rovide sample inputs and validate the outputs
nsure the pro ram handles errors as ell
Document the Analysis:
escri e hether the pro ram e ecuted ithout errors
rovide e amples of inputs and outputs to demonstrate functionality
ssess hether the code is ell or ani ed and easy to follo notin any areas
for improvement
Suggest Improvements:
ropose additional features such as live rate updates historical rate trac in
or a raphical user interface
er su estions on ho your peer could enhance the pro ram s functionality
or code reada ility
-0-
244 Computer Science , Grade 9