0% found this document useful (0 votes)
20 views14 pages

Section E

g

Uploaded by

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

Section E

g

Uploaded by

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

Questions

SECTION-E
36. Rohit is a librarian managing a library's database. The database stores
information about books with the following fields:
 Book_ID (integer)
 Book_Title (string)
 Author (string)
 Copies_Available (integer)
You, as a programmer, need to:
i) Write a function add_book(file_name) to input the data of a book and
append it to a binary file.
ii) Write a function update_availability(file_name) to update the number of
copies available for a book if the Copies_Available is less than 5. Add 5
more copies to the existing count.
iii) Write a function read_books(file_name) to display details of books
where the Copies_Available is greater than 10.
Ans: import pickle

# Function to add a book


def add_book(file_name):
file = open(file_name,"ab")
n=int(input("Enter no. of records:"))
for i in range(n):
book_id = int(input("Enter Book ID: "))
book_title = input("Enter Book Title: ")
author = input("Enter Author Name: ")
copies = int(input("Enter Copies Available: "))
book = {"Book_ID": book_id, "Book_Title": book_title, "Author":
author, "Copies_Available": copies}
pickle.dump(book, file)
print("Book added successfully!")
file.close()
file_name = "Library.dat"
add_book(file_name)

# Function to update availability


def update_availability(file_name):
#with open(file_name, "rb+") as file:
file = open(file_name,"rb+")
try:
while True:
position = file.tell() # Get the current position
book = pickle.load(file)
if book["Copies_Available"] < 5:
book["Copies_Available"] += 5
file.seek(position) # Move back to the start of the record
pickle.dump(book, file)
except EOFError:
file.close()
print("Availability updated successfully!")
file_name = "Library.dat"
update_availability(file_name)

# Function to read books


def read_books(file_name):
#with open(file_name, "rb") as file:
file = open(file_name,"rb")
try:
while True:
book = pickle.load(file)
if book["Copies_Available"] > 10:
print(book)
except EOFError:
file.close()
file_name = "Library.dat"
read_books(file_name)
37. Sunshine Tech Services is setting up its new campus in Chennai while the
Head Office is in Bangalore. The Chennai campus will have three buildings –
HR, DEVELOPMENT, and TESTING. You are tasked with providing
networking solutions to resolve the issues below:
Block-to-Block Distances (in meters):

Distance of Bangalore Head Office from Chennai Campus: 300 km


Number of Computers:

i) Suggest the most appropriate location of the server within the Chennai
campus. Justify your choice.
ii) Recommend a network device to connect all the computers in each
building.
iii) Design the cable layout to efficiently connect the buildings within the
Chennai campus and suggest the best type of cable for high-speed data
transfer.
iv) State whether a repeater is required in your cable layout. Provide a
justification.
v) Recommend a solution for live video communication between the
Chennai campus and the Bangalore Head Office. Choose from the
following options:
a. Email
b. Telephony
c. Video Conferencing
d. Instant Messaging
vi) Identify the type of network (PAN, LAN, MAN, or WAN) within:
a) Chennai Campus
b) Between Chennai Campus and Bangalore Head Office
Ans: i) Server Location:The DEVELOPMENT building is the most appropriate
location for the server since it has the highest number of computers (40).
Placing the server here minimizes network congestion and ensures efficient
data transfer.
ii) Network Device: A Switch is recommended to connect the computers
within each building as it efficiently manages traffic and supports high-speed
connectivity
iii) Cable Layout and Type:
 Layout: Draw a star topology where each building (HR,
DEVELOPMENT, TESTING) is connected to a central switch in the
DEVELOPMENT block.
 Cable Type: Use CAT-6 Ethernet cables for short distances and fiber-optic
cables for faster and reliable data transfer between blocks.
iv) Repeater Requirement: No repeater is required for the given layout as all
inter-building distances are under 100 meters, which is within the range of
CAT-6 and fiber-optic cables.
v) Live Video Communication Recommendation: Video Conferencing is the
best option for live visual communication between Chennai campus and
Bangalore Head Office, as it supports real-time interaction over long
distances.
vi) Network Types:
 Within Chennai Campus: Local Area Network (LAN).
 Between Chennai and Bangalore: Wide Area Network (WAN).

36. Dr. Meera is managing patient records in a hospital. The patient records include
the following details:
 Patient_ID (integer)
 Patient_Name (string)
 Disease (string)
 Days_Admitted (integer)
Tasks:
1. Write a function add_patient(file_name) to input and append patient
details to a binary file.
2. Write a function update_discharge(file_name) to update patient records
and discharge those whose Days_Admitted is greater than 20 by adding
"Discharged" to their record.
3. Write a function read_active_patients(file_name) to display the details of
patients who are still admitted.
Ans: import pickle

# Function to add a book


def add_patient(file_name):
file = open(file_name,"ab")
n=int(input("Enter no. of records:"))
for i in range(n):
patient_id = int(input("Enter Patient ID: "))
patient_name = input("Enter Patient Name: ")
disease = input("Enter Disease: ")
days_admitted = int(input("Enter Days Admitted: "))
patient = {"Patient_ID": patient_id, "Patient_Name": patient_name,
"Disease": disease, "Days_Admitted": days_admitted}
pickle.dump(patient, file)
print(" added successfully!")
file.close()
file_name = "Library.dat"
add_patient(file_name)

# Function to update availability


def update_discharge(file_name):
#with open(file_name, "rb+") as file:
file = open(file_name,"rb+")
try:
while True:
position = file.tell()
patient = pickle.load(file)
if patient["Days_Admitted"] > 20:
patient["Status"] = "Discharged"
file.seek(position)
pickle.dump(patient, file)
except EOFError:
file.close()
print("Availability updated successfully!")
file_name = "Library.dat"
update_discharge(file_name)

# Function to read books


def read_active_patients(file_name):
#with open(file_name, "rb") as file:
file = open(file_name,"rb")
try:
while True:
patient = pickle.load(file)
if patient.get("Status") != "Discharged":
print(patient)
except EOFError:
file.close()
file_name = "Library.dat"
read_active_patients(file_name)
37. ABC Ltd. is setting up a campus in Pune with four blocks: HR, IT, FINANCE,
and SALES. The block-to-block distances are:

The number of computers in each block is:

i) Suggest the most suitable block to house the server. Justify your answer.
ii) Draw the topology to connect all the blocks within the campus. Mention the
cable type you would recommend.
iii) Which device is best suited to connect computers within a block? Justify
your answer.
iv) Is a repeater required in the given network layout? Why or why not?
v) Identify the type of network (LAN, MAN, or WAN) within the campus and
between this campus and their Mumbai branch, which is 400 km away.
Ans: i) Suitable block to house the server:
The IT block should house the server as it has the maximum number of
computers (50), which will reduce the overall network traffic and ensure
faster data access for the most active users.
ii) Topology and recommended cable type:
 Suggested Topology: Star topology. It ensures centralized connectivity
with the server located in the IT block.
 Recommended Cable Type: Cat-6 Ethernet cable (supports higher
speeds over short distances).
iii) Device to connect computers within a block:
Use a switch to connect all computers within each block. A switch offers
better performance as it sends data only to the intended device.
iv) Is a repeater required?
A repeater is not required because the distances between blocks are less
than 100 meters, which is well within the range of Ethernet cables.
v) Network types:
Within the campus: LAN (Local Area Network).
Between Mumbai campus and Delhi head office: WAN (Wide Area
Network).

36. Karan is responsible for maintaining an inventory system for a store. The
inventory includes:
 Item_ID (integer)
 Item_Name (string)
 Category (string)
 Quantity (integer)
Tasks:
i) Write a function add_item(file_name) to input and append inventory
items to a binary file.
ii) Write a function update_stock(file_name) to increase the quantity of all
items under the "Electronics" category by 10.
iii) Write a function read_low_stock(file_name) to display all items whose
Quantity is less than 20.
Ans:
37. A college in Kolkata is setting up a network in its campus with the following
building distances and computer distribution:

i) Which building should house the central server? Provide a reason.


ii) Suggest the most efficient cable type for connectivity between the buildings
and justify your choice.
iii) If the LABS block and the HOSTEL block are separated by 120 meters, is
there a need for a repeater? Why or why not?
iv) Recommend an appropriate communication medium for connecting the
college with its parent university in Delhi, located 1,500 km away.
v) What is the type of network setup: within the college and between the
college and the parent university?
Ans: i) Building for the server:
The LABS block should house the server because it has the maximum
number of computers (50), reducing the overall traffic and ensuring better
speed for the most active users.
ii) Efficient cable type:
Use fiber optic cables for inter-building connectivity to ensure high-
speed and low-latency data transfer over longer distances.
iii) Repeater requirement:
 Between LABS and LIBRARY (140 meters): A repeater is required as
the distance exceeds the 100-meter limit of Ethernet cables.
 For distances within 100 meters, no repeater is needed.
iv) Communication medium for university connectivity:
Use a leased line or VPN over the internet for connecting the college
with its parent university, as it provides secure and reliable long-distance
communication.
v) Network types:
 Within the campus: LAN (Local Area Network).
 Between college and university: WAN (Wide Area Network).

36. Amit is managing employee records for his company. The employee data
includes:
 Employee_ID (integer)
 Employee_Name (string)
 Department (string)
 Salary (float)
Tasks:
i) Write a function add_employee(file_name) to input and append employee
data to a binary file.
ii) Write a function update_salary(file_name) to increase the salary of all
employees in the "IT" department by 15%.
iii) Write a function read_low_salary(file_name) to display details of
employees whose salary is below 30,000.
Ans:
37. A hospital is planning to network its buildings. The layout is as follows:

The distribution of computers:

i) Suggest the topology to connect all buildings efficiently.


ii) Which building should house the server, and why?
iii) Which hardware device would you use to connect all computers in a
building?
iv) Which transmission medium would you suggest for inter-building
connectivity and why?
v) Define the type of network (LAN, MAN, or WAN) established in this
hospital.
Ans: i) Topology:
Star topology is recommended to ensure centralized management and
faster communication between the server and other blocks.
ii) Building for the server:
The WARDS block should host the server as it has the maximum number
of computers (30).
iii) Device for connecting computers within a block:
Use a switch to connect computers within each building.
iv) Transmission medium:
Use Cat-6 Ethernet cables for connections up to 100 meters. For
distances exceeding 100 meters (e.g., WARDS to EMERGENCY), use
fiber optic cables.
v) Network type:
a. Within the hospital: LAN (Local Area Network).

36. Priya is responsible for managing student results. The result records include:
 Roll_Number (integer)
 Student_Name (string)
 Subject (string)
 Marks (integer)
Tasks:
1. Write a function add_result(file_name) to input and append student result
data to a binary file.
2. Write a function update_grade(file_name) to add a grade ("A", "B", "C",
etc.) based on the Marks scored by the student.
3. Write a function read_failed_students(file_name) to display the details of
students who scored less than 40 marks.
Ans:
37. A school in Ahmedabad has the following buildings to be networked:

i) Which building is the most suitable to host the central server? Explain your
answer.
ii) Suggest a topology and draw a layout for connecting all buildings.
iii) Recommend a suitable hardware device for connecting all computers in a
single building.
iv) Which cable type would you prefer for inter-building connections and why?
v) What type of network would be established within the campus and why?
Ans: i) Building for the server: The LABS block should house the server
because it has the maximum number of computers (50).
ii) Topology: Star topology is recommended to ensure better performance
and centralized control.
iii) Device for connecting computers within a block: Use a switch for
internal block connectivity.
iv) Cable type for inter-building connections: Use Cat-6 Ethernet cables
for distances up to 100 meters, and fiber optic cables for longer distances.
v) Network type:
Within the campus: LAN (Local Area Network).

You might also like