FileHandling - ComputerNetworks Support Material
FileHandling - ComputerNetworks Support Material
TEXT FILE
30 | P a g e
✔ While opening a text file, the text editor translates each ASCII value and shows us the equivalent
character that is readable by the human being.
✔ Each line of a text file is terminated by a special character, called the End of Line (EOL). For
example, the default EOL character in Python is the newline (\n).
Note: if file mode is not mentioned in open function, then default file mode, 'r' is used
31 | P a g e
Closing a file
• Once done with the read/write operations on a file, close the file.
• Python provides a close ( ) method to do so.
• While closing a file, the system frees the memory allocated to it.
• The syntax of close ( ) is:
file_object.close( )
Reads the entire file as one string Reads one line at a time Reads all lines into a list of strings
Use when you want to load the Call multiple times to read useful for looping through lines
whole file at once multiple lines
to read a specified number of used to read a specified using readlines( ) function, lines in the
bytes use number (n) of bytes of data file become members of a list, where
[Link](n) from a file but maximum up each list element ends with a newline
to the newline character character (‘\n’)
(\n)
[Link](n)
32 | P a g e
SETTING OFFSETS IN A FILE
• The tell ( ) method • The seek ( ) method
This function returns an integer that This method is used to position the file object at a
specifies the current position of the file particular position in a file.
object in the file.
The position specified is the byte position In the given syntax, offset is the number of bytes by
from the beginning of the file till the current which the file object is to be moved. reference_point
position of the file object. indicates the starting position of the file object.
That is, with reference to which position, the offset has
to be counted. It can have any of the following values:
0 - beginning of the file
1 - current position of the file
2 - end of file
The syntax of using tell ( ) is: The syntax of seek ( ) is:
file_object.tell( ) file_object.seek(offset [, reference_point])
33 | P a g e
4. What will [Link]("Hello\nWorld") do in a text file?
a. Write the string without a newline b. Raise an error
c. Write "Hello World" on a single line d. Write "Hello" and "World" on separate lines
5. The correct syntax of seek( ) is:
a. file_object.seek(offset [, reference_point]) b. seek(offset [, reference_point])
c. seek(offset, file_object) d. seek.file_object(offset)
6. What will be the output of the following statement in python? (fh is a file handle)
[Link](-30,2)
Options:- It will place the file pointer:-
a. at 30th byte ahead of current file pointer position
b. at 30 bytes behind from end-of file
c. at 30th byte from the beginning of the file
d. at 5 bytes behind from end-of file.
7. Which Python function is used to open a text file for reading?
a. open ("[Link]", "w") b. open ("[Link]", "r")
c. read("[Link]") d. write("[Link]")
8. Text file [Link] is stored in the storage device. Identify the correct option out of the
following options to open the file in read mode.
i. myfile = open('[Link]','rb')
ii. myfile = open('[Link]','w')
iii. myfile = open('[Link]','r')
iv. myfile = open('[Link]')
a. only i b. both i and iv c. both iii and iv d. both i and iii
9. What is the correct way to ensure a file is automatically closed after reading?
a) [Link]( ) b) with open('[Link]') as file:
c) open('[Link]').close( ) d) read([Link])
10. State True or False.
The writelines( ) method automatically adds newline characters (\n) after each line.
ANSWERS:
1 b) Opens a file for reading only 2 c) seek( )
3 d) [Link]( ) 4 d) Write "Hello" and "World" on
separate lines
5 a) file_object.seek(offset [, reference_point]) 6 b) at 30 bytes behind from end-of file
7 b) open("[Link]", "r") 8 c) both iii and iv
9 b) with open('[Link]') as file: 10 False
ASSERTION (A) and REASONING (R)
Mark the correct choice as
(a) Both (A) and (R) are true and (R) is the correct explanation for (A).
(b) Both (A) and (R) are true and (R) is not the correct explanation for (A).
(c) (A) is true but (R) is false.
(d) (A) is false but(R) is true.
1. Assertion (A): Opening a file in 'a' mode will delete its previous content.
Reason (R): The 'a' mode appends new data at the end of the existing file content.
2. Assertion (A): The with statement ensures a file is properly closed after its block finishes.
Reason (R): Using with avoids the need to explicitly call close ( ) on a file object.
3. Assertion (A): Files must be closed using the close ( ) function to ensure data is saved properly.
Reason (R): Not closing a file may result in data loss or corruption
34 | P a g e
4. Assertion (A): Opening a file in write mode(‘w’) will delete its existing contents.
Reason (R): In Python, the ‘w’ mode creates a new file if it doesn't exist, but preserves old
content if the file exists.
5. Assertion (A): The writelines( ) method adds newline characters automatically after each line.
Reason (R): writelines( ) writes a list of strings.
Answers
1 (a) Both (A) and (R) are true and (R) is the correct explanation for (A).
2 (d) (A) is false but(R) is true.
3 (a)Both A and R are true, and R is the correct explanation of A.
4 (c)A is true, R is false.
5 (d) A is false, R is true
Short Answer Type Questions
1. Display words longer than 5 characters from [Link]
2. Write a function in Python that counts the number of “the” or “this” words present in a text
file “[Link]”.
Example: If the “[Link]” contents are as follows:
This is my first class on Computer Science. File handling is the easiest topic for me and
Computer Networking is the most interesting one.
The output of the function should be: Count of the/this in file
3. Write a Python program to count all the line having 'a' as last character.
4. Observe the following code and answer the questions that follow.
File=open(“MyData”,”a”)
_____________ #Blank1
[Link]( )
a) What type (text/binary) of file is MyData ?
b) Fill the Blank1 with statement to write “ABC” in the file “Mydata”
5. What does the split( ) function do when used on a line read from a text file? Explain with
example.
Answers
1 #Display words longer than 5 characters from [Link]
f=open("[Link]", "r")
lines = [Link]( )
for line in lines:
for word in [Link]( ):
if len(word) > 5:
print(word)
2 def displayTheThis( ):
num=0
f=open("[Link]","r") N=[Link]( ) M=[Link]( )
for x in M:
if x=="the" or x== "this":
print(x)
num=num+1
[Link]( )
print ("Count of the/this in file:",num)
3 #Number of lines having 'a' as last character
count =0
35 | P a g e
f=open('[Link]',"r")
data=[Link]( )
for line in data:
if line[-2] == 'a':
count=count+1
print("Number of lines having 'a' as last character is/are : " ,count)
[Link]( )
4 a) Text File b) [Link](“ABC”)
5 The split ( ) function breaks a string into a list of words using whitespace as the default
separator.
line = "Hello world"
print([Link]( ))
output
['Hello', 'world']
Long Answer Type Questions
1. Program to count number of “ME” or “MY” in a text file [Link]
Ans #Program to count number of "ME" or "MY" in a text file [Link]
def countwords( ):
f=open("D:\\xiic\\[Link]","r")
count=0
1st=[Link]( )
for i in [Link]( ):
if [Link]( )=="Me".upper ( ) or [Link] ( )=="My".upper( ):
count=count+1
print ("Number of me or my is", count)
[Link]( )
countwords( )
2. Program to count number of “a” or “m” in a text file [Link]
Ans # def countAM( ):
f=open("D:\\xiic\\[Link]","r"}
countA=0
countM=0
CON=[Link]( )
for i in CON:
if [Link]( )=='A':
countA=countA+1
elif [Link]( ) == 'M':
countM=countM+1
print ("Number of A is ", countA, "\nNumber M is:", countM)
[Link]( )
countAM ( )
3 Program to count number of lines starting with “M”
Ans #Program to count number of lines starting with “M”
def countlines( ):
f=open("D:\\xiic\\[Link]","r")
36 | P a g e
count1=0
LN=[Link]( )
for i in LN:
If i[0]=="M":
count1+=1
print("Number of lines starting with M=", count1)
[Link]( )
countlines ( )
4 Program to print lines not staring with a vowel from a text file [Link]
Ans #Program to print lines not staring with a vowel from a text file [Link]
def COUNTLINES( ):
file lines
count=0
open ('D:\\XIIC\\[Link]', 'r') [Link] ( )
for w in lines:
if (w[0]).lower( ) not in 'aeoiu':
count count + 1
print ("The number of lines not starting with any vowel: ", count)
[Link]( )
COUNTLINES( )
5 Write a function ETCount( ) in Python, which should read each character of a text file
“[Link]” and then count and display the count of occurrence of alphabets E and T
individually (including small cases e and t too)
Ans #Write a function ETCount( ) in Python, which should read each character of a tex
def ETCount( ):
file open ('D:\\XIIC\[Link]', 'r')
lines=[Link]( )
countE=0
countT=0
for ch in lines:
if ch in 'Ee':
countEcountE + 1
if ch in 'Tt':
countT-countT+ 1
print ("The number of E or e: ", countE) print ("The number of T or t : ", countT)
[Link]( )
ETCount( )
6 Program to count the word “AND” in a text file [Link]
Ans #Program to count the word "AND" in a text file [Link].
def COUNT_AND( ):
count=0
file=open('D:\\XIIC\\[Link]', 'r')
line=[Link]( )
word=[Link]( )
for w in word:
37 | P a g e
if w in ['AND', 'and', 'And']:
count=count+1
print ("Number of word And is", count)
[Link]( )
COUNT_AND ( )
7 Write a function in Pyton to read lines from a text file [Link], and display only those lines,
which are starting with an alphabet 'P'.
Ans #Write a function in Pyton to read lines from a text file [Link], and #display only those
lines, which are starting with an alphabet 'p'.
def rdlines( ):
file= open('D:\\XIIC\\[Link]','r')
lines=[Link] ( )
for line in lines:
if line[0] == 'p':
print (line)
[Link]( )
rdlines ( )
8 Program to remove lines starting with @ and write it into another file.
Ans def filter( ):
fin=open("d:\\xiic\\[Link]","r")
fout=open("d:\\xiic\\[Link]", "w")
text=[Link] ( )
for i in text:
if i[0]!="@":
[Link](i)
[Link]( )
[Link]( )
def showcontent ( ) :
fin=open("d:\\xiic\\[Link]","r"}
text=[Link]( )
print (text)
[Link]( )
filter( )
showcontent( )
BINARY FILE
A binary file is a file whose content is in a binary format (0s and 1s). It stores data as a sequence of bytes
(each byte = 8 bits). Binary files include a wide range of file types, including executables, libraries,
graphics, databases, archives and many others.
There are mainly two types of data files — text file and binary file.
Differences between text files and binary files.
S. No. Text file Binary File
1. The text files can easily be transferred Binary files cannot easily be transferred from
from one computer system to another. one computer system to another due to
variations.
38 | P a g e
2. It stores data using ASCII format i.e. It stores data in binary format i.e. with the help
human-readable graphic characters. of 0 and 1.
3. These files are easily readable and These files are not easily readable and
modifiable because the content written in modifiable because the content written in binary
text files is human readable. files is not human-readable and it is encrypted
content.
Steps to process a binary file
• Opening a file
• Writing data into a file
• Reading data from a file
• Closing a file
Opening a Binary file in Python
Opening a file refers to getting the file ready either for reading or for writing.
To open a file in Python, we use the open ( ) function.
39 | P a g e
Pickling/Serialization: The process of converting the structure (lists and dictionary etc.) into a byte
stream just before writing to the file.
Unpickling/De-serialization: The reverse of pickling process where information from byte stream gets
converted into object structure.
42 | P a g e
2. Nila wants to store a list of dictionaries into a binary file. Which of the following Python
modules should she use?
a) os b) csv c) pickle d) json
3. Pick the correct syntax to read a binary file using pickle:
a) [Link](file) b) [Link](file)
c) [Link](file) d) [Link](file)
4. What does the [Link](obj, file) function do?
a) Reads binary data from a file
b) Writes text data to a file
c) Converts a Python object into byte stream and writes it to a file
d) Appends an object to a list
5. Which file mode should be used to write a binary file in Python?
a) 'w' b) 'r' c) 'wb' d) 'rb'
6. What will happen if you try to read a binary file using 'r' mode instead of 'rb'?
a) It will read data correctly.
b) It will raise a SyntaxError.
c) It will convert binary data into text
d) It may raise an error or return incorrect data
7. Which of the following is a key advantage of binary files over text files?
a) Easy to read with any text editor
b) Allows direct storage of complex Python objects
b) Consumes more storage space
d) Cannot be shared across system
Answers :
1 C 2 C 3 B 4 C
5 C 6 D 7 B
52 | P a g e
CSV stands for Comma Separated Values CSV file is a type of plain text file means data stored in form of
ASCII or Unicode characters Each line is a row and in row each piece of data is separated by a comma It
is common format for data interchange.
[Link]( ) The [Link]( ) function in Python is used to read data from a CSV (Comma
Separated Values) file. It is part of Python’s built-in csv module.
[Link](file_object, delimiter=',')
Parameters:
• file_object: A file object opened using open( ).
• delimiter: (Optional) Specifies the character used to separate fields. Default is
comma (,).
It returns an iterator that returns each row in the CSV file as a list of strings.
Example
import csv
with open('[Link]', 'r') as file:
reader = [Link](file)
for row in reader:
print(row)
[Link]( ) The [Link]( ) function in Python is used to write data to a CSV file. It is part of
Python’s built-in csv module and writes rows as comma-separated values.
[Link](file_object, delimiter=',')
53 | P a g e
Parameters:
• file_object: A file object opened in write ('w') or append ('a') mode.
• delimiter: (Optional) Character that separates values. Default is comma (,).
• It returns a writer object that lets you write rows (lists or tuples) to the CSV
file.
Common Methods:
• [Link](row) → Writes a single row.
• [Link](list_of_rows) → Writes multiple rows.
Example:
import csv
with open('[Link]', 'w', newline='') as file:
writer = [Link](file)
# Write header
[Link](['Name', 'Age', 'City'])
# Write multiple data rows
[Link]([['Alice', 23, 'Delhi'],['Bob', 30, 'Mumbai'] ])
55 | P a g e
1(ii) import csv
def COUNTR( ):
f=open('[Link]','r')
c=0
data=[Link](f)
for x in data:
c=c+1
print(c)
COUNTR( )
2. Create a function maxsalary( ) in Python to read all the records from an already existing file
[Link] which stores the records of various employees working in a department. Data is
stored under various fields as shown below:
E_code E_name Scale Salary
A01 Bijesh Mehra S4 65400
B02 Vikram Goel S3 60000
C09 Suraj Mehta S2 45300
Function should display the row where the salary is maximum.
Note: Assume that all employees have distinct salary.
Ans import csv
def maxsalary( ):
f=open('[Link]', 'r')
reader=[Link] (f)
skip_header = True
m= 0
for row in reader:
if skip_header:
skip_header = False
else:
if(int(row[3])>m):
m=int(row[3])
rec=row
print('Row with the highest salary: ', rec)
[Link]( )
maxsalary( )
3. A csv file "[Link]" contains the data of a survey. Each record of the file contains the
following data:
• Name of a country
• Population of the country
• Sample Size (Number of persons who participated in the survey in that country)
• Happy (Number of persons who accepted that they were Happy)
For example, a sample record of the file may be:
[‘Signiland’, 5673000, 5000, 3426]
Write the following Python functions to perform the specified operations on this file:
56 | P a g e
a) [10, 20, 30] b) [10, 20]
c) [20, 30] d ) Error
5. What happens if you call pop ( ) on an empty stack?
a) Returns None b) Raises IndexError
c) Returns -1 d) Does nothing
Answers
1. B 2. C 3. C 4. B 5. B
64 | P a g e
print([Link]( ))
else:
print("Stack empty")
2. Consider a list named Nums which contains random integers. Write the following user
defined functions in Python and perform the specified operations on a stack named
BigNums.
(i) PushBig( ): It checks every number from the list Nums and pushes all such numbers
which have 5 or more digits into the stack, BigNums.
(ii) PopBig( ): It pops the numbers from the stack, BigNums and displays them. The
function should also display "Stack Empty" when there are no more numbers left in the
stack.
For example: If the list Nums contains the following data:
Nums = [213, 10025, 167, 254923, 14, 1297653, 31498, 386, 92765]
Then on execution of PushBig( ), the stack BigNums should store:
[10025, 254923, 1297653, 31498, 92765]
And on execution of PopBig( ), the following output should be displayed:
92765
31498
1297653
254923
10025
Stack Empty
Ans def PushBig(Nums,BigNums):
for N in Nums:
if len(str(N)) >= 5:
[Link](N)
def PopBig(BigNums):
while BigNums:
print([Link]( ))
else:
print("Stack Empty")
3. A list contains following record of course details for a University:
[Course_name, Fees, Duration]
Write the following user defined functions to perform given operations on the stack
named 'Univ' :
(i) Push_element( ) - To push an object containing the Course_name, Fees and Duration
of a course, which has fees greater than 100000 to the stack.
(ii) Pop_element( ) - To pop the object from the stack and display it. Also, display
“Underflow” when there is no element in the stack.
For example:
If the lists of courses details are:
65 | P a g e
["MCA", 200000, 3]
["MBA", 500000, 2]
["BA", 100000, 3]
The stack should contain
["MBA", 500000, 2]
["MCA", 200000, 3]
Ans Univ=[]
def Push_element(Course):
for Rec in Course:
if Rec[1]>100000:
[Link](Rec)
def Pop_element( ):
while len(Univ)>0:
print([Link]( ))
else:
print("Underflow")
4. Write separate user defined functions for the following:
(i) PUSH(N) - This function accepts a list of names, N as parameter. It then pushes only
those names in the stack named OnlyA which contain the letter 'A'.
(ii) POPA(OnlyA) - This function pops each name from the stack OnlyA and displays it.
When the stack is empty, the message "EMPTY" is displayed.
For example :
If the names in the list N are
['ANKITA', 'NITISH', 'ANWAR', 'DIMPLE', 'HARKIRAT']
Then the stack OnlyA should store
['ANKITA', 'ANWAR', 'HARKIRAT']
And the output should be displayed as
HARKIRAT ANWAR ANKITA EMPTY
Ans OnlyA=[ ]
def PUSH(N):
for aName in N :
if 'A' in aName :
[Link](aName)
def POPA(OnlyA):
while OnlyA :
print([Link]( ), end=' ')
else :
print('EMPTY')
5. Write the following user defined functions:
(i) pushEven(N) - This function accepts a list of integers named N as parameter. It then
pushes only even numbers into the stack named EVEN.
66 | P a g e
(ii) popEven(EVEN) - This function pops each integer from the stack EVEN and displays
the popped value. When the stack is empty, the message "Stack Empty" is displayed.
For example:
If the list N contains:
[10,5,3,8,15,4]
Then the stack, EVEN should store
[10,8,4]
And the output should be
4 8 10 Stack Empty
Ans EVEN=[ ]
def pushEven(N):
for z in N :
if z%2==0 :
[Link](z)
def popEven(EVEN):
while EVEN :
print([Link]( ), end=' ')
else :
print('Stack Empty')
6. Write the definition of a user defined function PushNV(N) which accepts a list of strings in
the parameter N and pushes all strings which have no vowels present in it, into a list named
NoVowel.
Write a program in Python to input 5 Words and push them one by one into a list named
[Link] program should that use the function PushNV( ) to create a stack of words in the
list NoVowel so that it stores only those words which do not have any vowel present in it,
from the list [Link], pop each word from the list NoVowel and display the popped
word. When the stack is empty, display the message "EmptyStack".
Ans def PushNV(N):
for W in N :
for C in W :
if [Link]( ) in 'AEIOU':
break
else:
[Link](W)
All=[ ]
NoVowel=[ ]
for i in range(5) :
[Link](input('Enter a Word: '))
PushNV(All)
while NoVowel :
print([Link]( ), end=' ')
else :
print('EmptyStack')
67 | P a g e
UNIT 2
COMPUTER NETWORKS
Concept Map:
Network: A group of two or more similar things or people interconnected with each other is called
network. Examples are social network and mobile network
Computer Network: A Computer network is an interconnection among two or more computers or
computing devices. The advantages of computer networks are:
• Resource Sharing
• Collaborative Interaction
• Cost Saving
• Increased storage
• Time Saving
68 | P a g e
EVOLUTION OF NETWORK:
(I)ARPANET (Advanced Research Project Agency Network)
• It came into existence in 1960s
• A project for interconnecting, US department of defense with academic and research organization
across different places for scientific collaboration.
(II)NSFNET (National Science Foundation Networks)
• It came into existence in 1986
• It was the first large-scale implementation of Internet technologies in a complex environment of
many independently operated networks
(III) INTRANET
• It is a local or restricted communication system
• It is managed by a person or organization.
• Intranet users can avail services from internet but Internet user cannot access intranet directly
(IV) INTERNET
• It came into existence in 1960s
• It is known as Network of Networks
• A global computer network providing variety of information and communication facilities
consisting of interconnected networks using standardized communication protocols.
DATA COMMUNICATION TERMINOLOGIES
DATA: Data means information in digital form such as text, audio, video which is stored processed and
exchanged between digital devices like computer, mobile phones or laptop. Computers process the raw
data into meaningful information. Information is processed data.
COMMUNICATION: The exchange of information between two or more networked or interconnected
devices is called communication
COMPONENTS OF DATA COMMUNICATION
a) SENDER: Sender is a device which is capable of sending data over a communication network. In data
communication Sender is also called Source.
b) RECEIVER: Receiver is a device which is capable of receiving data over a communication network. In
data communication Receiver is also called Destination.
c) MESSAGE: message is the information being exchanged between a sender and a receiver over a
communication network.
d) COMMUNICATION MEDIUM: Communication medium is the path or channel through which the
information is moved from the sender to the receiver. A communication medium can be either
wired/guided or wireless/unguided.
e) PROTOCOLS: The set of standard rules which are followed in data communication are known as Data
Communication Protocols. All the communicating devices like sender receiver and other connected
devices in the network should follow these protocols.
Why Protocols are needed?
The communicating devices may be in different geographical areas. The speed of these devices may be
different. Also, the data transfer rates of different networks may be different. These complexities make
it necessary to have a common set of rules to ensure the secure communication of data. Some commonly
used Protocols in data communication are:
69 | P a g e
• Transmission Control Protocol (TCP)
• Internet Protocol (IP)
• File Transfer Protocol (FTP)
• Simple Mail Transport Protocol (SMTP)
• Hyper Text Transfer Protocol (HTTP)
IP ADDRESS: IP address or Internet Protocol address is a unique numeric address assigned to every
device connected to a network. It uniquely identifies every node connected to a local network or
internet. Example IP address: [Link]
SWITCHING TECHNIQUES
In large networks, there may be more than one paths for transmitting data from sender to receiver. The
process of selecting a path of data out of the available paths is called switching. There are two popular
switching techniques – circuit switching and packet switching.
1. Circuit Switching : In circuit switching, whenever a source end node wants to send a message to the
destination end node a physical link is first established between the source and the destination. Then
only the data transmission takes place. Example: telephone network
2. Packet Switching : In the packet switching technique, the whole message is split into small packets.
Now, these packets are transmitted one by one from sender to the receiver through the intermediary
switches in the network. The packets will take shortest path as possible.
TRANSMISSION MEDIA
• Transmission media are the channels used to carry data signals.
• They are broadly classified into
o Wired / Guided Media
Includes:
▪ Twisted pair cable
▪ Coaxial cable
▪ Fiber-optic cable
Features:
▪ High Speed
70 | P a g e
▪ Secure
▪ Used for comparatively shorter distances
o Wireless/Un-guided media
Includes:
▪ Radio waves
▪ Microwaves
▪ Infrared waves.
Features:
▪ The signal is broadcasted through air
▪ Less Secure
▪ Used for larger distances
71 | P a g e
• Coaxial Cable:
o Coaxial cable has an outer plastic covering containing an insulation layer made of PVC or
Teflon and 2 parallel conductors each having a separate insulated protection cover.
o The coaxial cable transmits information in two modes: Baseband mode(dedicated cable
bandwidth) and Broadband mode(cable bandwidth is split into separate ranges).
o Cable TVs and analog television networks widely use Coaxial cables.
72 | P a g e
Advantages of Optical Fibre Cable
• Increased capacity and bandwidth
• Lightweight
• Less signal attenuation
• Immunity to electromagnetic interference
• Resistance to corrosive materials
Disadvantages of Optical Fibre Cable
• Difficult to install and maintain
• High cost
Applications of Optical Fibre Cable
o Medical Purpose: Used in several types of medical instruments.
o Defence Purpose: Used in transmission of data in aerospace.
o For Communication: This is largely used in formation of internet cables.
o Industrial Purpose: Used for lighting purposes and safety measures in designing the interior
and exterior of automobiles.
NETWORK DEVICES
Modem: Stands for "modulator-demodulator.", converts digital data from a computer into analog signals
for transmission over telephone lines or cable systems. Also it converts incoming analog signals back
into digital data for the computer. Used to connect to the internet via ISP (Internet Service Provider).
74 | P a g e
Ethernet Card: Also known as a network interface card (NIC)., enables a computer to connect to an
Ethernet network using Ethernet cables, Essential for wired network connections. Provides a physical
interface for networking using an RJ45 connector
RJ45 Connector: Registered Jack 45 connector, used to connect Ethernet cables to devices such as
computers, switches, and routers, Ensures a secure and reliable physical connection. Repeater:
Amplifies and retransmits signals in a network, extends the range of network signals, especially in large
or congested environments. Used to combat signal loss over long distances.
Hub: A basic networking device that connects multiple devices in a network, Broadcasts data to all
connected devices, causing network congestion and inefficiency, which can lead to collisions.
Switch: Intelligent device that connects devices in a network, Forwards data only to the device that
needs it, improving network performance and efficiency by reducing collisions.
Router: Manages traffic between different networks, such as your home network and the internet,
performs functions like assigning IP addresses, directing data, and providing security.
Gateway: Acts as an entry and exit point for data traveling between different networks or protocols
(e.g., LAN to WAN), translates data between different formats or protocols to ensure smooth
communication.
Wi-Fi Card: A wireless network adapter that allows a computer to connect to Wi-Fi networks.
Commonly found in laptops and mobile devices for wireless internet access
75 | P a g e
NETWORKING TOPOLOGIES
Bus
It uses a single cable, called a trunk or segment, along which all the computers of the network are
connected
Star
All computers are connected using cable segments to a central component called a switch. The signals
from the transmitting computer go through the switch to all the others.
Tree
Tree Topology is a topology which is having a tree structure in which all the computers are connected
like the branches which are connected with the tree.
NETWORK PROTOCOL: A protocol means the rules that are applicable for a network. Protocols
defines standardized formats for data packets, techniques for detecting and correcting errors etc.
TCP/IP (Transmission Control Protocol/ Internet Protocol)
• The IP protocol ensures that each computer or node connected to the Internet is assigned an IP
address, which is used to identify each node independently.
• TCP ensures that the message or data is broken into smaller chunks, called IP packets. Each of
these packets are routed (transmitted) through the Internet, along a path from one router to the
next, until it reaches the specified destination. TCP guarantees the delivery of packets on the
76 | P a g e
designated IP address. It is also responsible for ordering the packets so that they are delivered in
sequence.
FTP (File Transfer Protocol): It is a standard internet protocol provided by TCP/IP used for
transmitting the files from one host to another. It is mainly used for transferring the web page files from
their creator to the computer that acts as a server for other computers on the internet. It is also used for
downloading the files to computer from other servers.
SMTP (Simple Mail Transfer Protocol.): SMTP is a set of communication guidelines that allow
software to transmit an electronic mail over the internet is called Simple Mail Transfer Protocol.
Point-to-Point Protocol (PPP) is protocol that is used to directly connect one computer system to
another. Computers use PPP to communicate over the telephone network or the Internet.
Post Office Protocol version 3 (POP3) Protocol: (POP3) is a standard mail protocol used to receive
emails from a remote server to a local email client. POP3 allows you to download email messages on
your local computer and read them even when you are offline. J, and JVM
Telnet: Telnet is a program that allows a user to log on to a remote computer. Telnet provides a
connection to the remote computer in such a way that a local terminal appears to be at the remote side.
VoIP: VoIP stands for Voice over Internet Protocol. It is also referred to as IP telephony, internet
telephony, or internet calling.
Web Services: Web Services means the services provided by World Wide Web. The World Wide Web
provides services like chatting, emailing, video conferencing, e-learning, e-shopping, e-reservation, e-
groups and social networking.
World Wide Web (WWW): The World Wide Web commonly referred to as WWW, W3, or the Web is
an interconnected system of public webpages accessible through the Internet. It was invented by Tim
Berners-Lee in 1989. Major components of WWW are:
1. Web Server – It is a computer that stores website resources (web pages, images, videos, etc.).
2. Web Browser (Client) - A software application used to access the web resources.
3. Webpage - Hypertext documents formatted in Hypertext Mark-up Language (HTML) and
displayed in a web browser.
4. Website - A website is a collection of inter-linked web pages that is identified by a common
domain name (website name) and stored on a web server.
5. HTTP Protocol - It governs data (web page) transfer between a server and a client.
6. HTML- A mark-up language used to specify the structure of a webpage.
7. URL- Address used to identify documents and other web resources on the internet.
WEB ARCHITECTURE
Web is working based on a client-server architecture.
Client: It is a computer capable of requesting, receiving & displaying information in the form of web
pages or using a particular service from the service providers (Servers).
77 | P a g e
Servers: It is a remote computer which provides/transfers information to the client (in the form of web
pages) or access to particular services.
Difference between Internet and WWW
Internet World Wide Web(WWW)
Internet stands for Interconnected Networks WWW stands for World wide Web
Internet is a means of connecting a computer World Wide Web which is a collection of
to any other computer anywhere in the world. information which is accessed via the Internet.
Internet is infrastructure. WWW is service on top of that infrastructure.
Internet is primarily hardware-based WWW is more software-oriented as compared to
the Internet.
Internet uses TCP/IP protocol. WWW uses HTTP Protocol.
HTML (Hypertext Mark-up Language): It is a mark-up language that tells web browsers how to
structure the web pages you visit. It has a variety of tags and attributes for defining the layout and
structure of the web document. A HTML document has the extension .htm or .html. Hypertext is a text
which is linked to another html document via clickable links known as hyperlinks.
XML (eXtensible Mark-up Language): XML is a mark-up language like HTML but it is designed to
transport or store data. It does not have predefined tags but allows the programmer to use customized
tags. An XML document has the extension .xml.
HTML v/s XML
HTML XML
HTML stands for Hyper Text Mark-up Language XML stands for eXtensible Mark-up Language
HTML is a case insensitive. XML is case sensitive.
Predefined tags (commands). User defined tags (commands).
It is used for presentation of the Data. It is used for transportation of the Data.
Small errors can be ignored. Errors not allowed.
Closing tags are optional. Compulsory to use closing tags.
HTTP - Hyper Text Transfer Protocol: HTTP is used to transfer data across the web. HTTP specifies
how to transfer hypertext (linked web documents) between two computers. It allows users of the World
Wide Web to exchange information found on web pages.
Hypertext Transfer Protocol Secure (HTTPS) is an extension of the HTTP which is used for secure
communication over a computer network.
Domain Names: Every device connected to the Internet has a numeric IP address which is very difficult
to remember. Each computer server hosting a website or web resource is given a name known as
Domain Name corresponding to unique IP addresses. For example, IP addresses and domain names of
some websites are as follows:
Domain Name IP Address
[Link] [Link]
[Link] [Link]
78 | P a g e
The process of converting a hostname (such as [Link]) into the corresponding IP address
(such as [Link]) is called domain name resolution. Specialized DNS servers are used for domain
name resolution (DNS resolution).
URL-Uniform Resource Locator: Every web page that is displayed on the Internet has a specific
address associated with it, this address is known as the URL. The structure of a URL can be represented
as follows:
[Link]
79 | P a g e
a. Connected devices share the resources of a single processor or server within a small
geographic area
b. Normally find within a business and school
c. These are computers that share resources over a large area
d. None of the above
4 Mr. John is a small businessman who runs Hardware store. He has been experiencing problems
with his small accounting department, which he depends on to provide sales reports. Mr. John
wants to share information between his 7 computer stations and have one central printing
area. What type of network would you recommend to Mr. John?
a. MAN b. LAN c. WAN d. SAN
5 WAN covers a larger geographical area than MAN?
a. True b. False
6 A network that consists of both LANs and MANs is called a Wide area network?
a. True b. False
7 Arrange the Following Types of Networks according to their size, from largest to smallest?
a. LAN, WAN, MAN b. WAN, LAN, MAN
c. MAN, LAN, WAN d. WAN, MAN, LAN
8 You are a member of a club that deals with computer networks. The club has to take a project
to build a MAN. Where would this project likely take place?
a. A small building/organization b. University or college
c. Home d. None of the above
9 What is the full form of MAN ?
a. Magnetic Access Network b. Metropolitan Area Network
c. Multi-Area Network d. Multi-Access net
10 In your school there is a library, and you can use the internet to do research, this library will
most likely be a WAN network?
a. True b. False
11 Types of Networks are Categories by their Geographical Area cover?
a. True b. False
12 What’s a web browser?
a) A kind of spider
b) A computer that store www files
c) A person who likes to look at websites
d) A software program that allows you to access sites on the World Wide Web
13 A _____ is a document commonly written and is accessible through the internet or other network
using a browser?
a) Accounts b) Data c) Web page d) Search engine
14 Which of the following is used to read HTML code and to render Webpage?
a) Web Server b) Web Browser c) Web Matrix d) Weboni
15 Which of the following is a Web Browser?
a) MS-office b) Notepad c) Firefox d) Word 2007
80 | P a g e