33. Infotainment Ltd. is an event management company with its prime office located in Bengaluru. The company is planning to open its new division at three different locations in Chennai named as - Vajra, Trishula and Sudershana.
You, as a networking expert need to suggest solutions to the questions in part (i) to (v), keeping in mind the distances and other given parameters.
Distances between various locations:
| Vajra to Trishula |
350 m |
| Trishula to Sudershana |
415 m |
| Sudershana to Vajra |
300 m |
| Bengaluru Office to Chennai |
2000 km |
Number of computers installed at various locations:
| Vajra |
120 |
| Sudershana |
75 |
| Trishula |
65 |
| Bengaluru Office |
250 |
(i) Suggest and draw the cable layout to efficiently connect various locations in Chennai division for connecting the digital devices.
Ans:
(ii) Which block in Chennai division should host the server? Justify your answer.
Ans: Vajra can host the server as it has a maximum number of computers.
(iii) Which fast and effective wired transmission medium should be used to connect the prime office at Bengaluru with the Chennai division?
Ans: Optical Fiber
(iv) Which network device will be used to connect the digital devices within each location of Chennai division so that they may communicate with each other?
Ans: Switch / Hub / Router
(v) A considerable amount of data loss is noticed between different locations of the Chennai division, which are connected in the network. Suggest a networking device that should be installed to refresh the data and reduce the data loss during transmission to and from different locations of Chennai division.
Ans: Repeater
34. (A) (i) Differentiate between 'w' and 'a' file modesin Python.
Ans:
'w' Write Mode:
- Open the file in write mode.
- If the file doesn't exist, then a new file will be created.
- The file pointer is in the beginning of the file.
- If the file exists, the contents of the file, if any, are lost/truncated and the new data is added as fresh data into the file.
'a' Append Mode:
- Open the file in append mode.
- If the file doesn't exist, then a new file will be created.
- The file pointer is at the end of the file.
- If the file exists, the new data is added at the end of the file without deleting the previous contents of the file.
(ii) Consider a binary file, items.dat, containing records stored in the given format:
{item_id: [item_name, amount] }
Write a function, Copy_new(), that copies all records whose amount is greater than 1000 from items.dat to new_items.dat.
Ans:
import pickle
def Copy_new():
F2=open("new_items.dat", "wb")
try:
F1=open("items.dat","rb")
Datal-pickle.load(F1)
Data2={}
for K,V in Datal.items():
if V[1]>1000:
Data2 [K]=V
pickle.dump (Data2, F2)
F2.close()
except:
print("File not found!")
F1.close()
OR
(B) (i) What is the advantage of using with clause while opening a data file in Python ? Also give syntax of with clause.
Ans: The main advantage of using the with clause while opening a file in Python is that the file is automatically closed after the block of code is executed, even if an error occurs.
This makes the code safer, cleaner, and avoids memory/resource leaks.
Syntax of with clause:
with open(file_name, access_mode) as file_object:
# statements
Example:
with open("myfile.txt", "r+") as file_object:
content = file_object.read()
(ii) A binary file, EMP.DAT has the following structure:
[Emp Id, Name, Salary]
where
Emp _Id: Employee id
Name: Employee Name
Salary: Employee Salary
Write a user defined function, disp_Detail (), that would read the contents of the file EMP.DAT and display the details of those employees whose salary is below 25000.
Ans:
def disp_Detail ():
try:
with open ("EMP.DAT","rb") as F:
Data-pickle.load (F)
for D in Data:
if D [2]<25000:
print (D)
except:
print("File Not Found!!!")
35 (A) (i) Define cartesian product with respect to RDBMS.
Ans: Cartesian Product operation combines rows/tuples from two tables/relations. It results in all the pairs of rows from both the tables. It is denoted by 'X'.
(ii) Sunil wants to write a program in Python to update the quantity to 20 of the records whose item code is 111 in the table named shop in MySQL database named Keeper.
The table shop in MySQL contains the following attributes :
Item_code: Item code (Integer)
Item_name: Name of item (String)
Qty: Quantity of item (Integer)
Price: Price of item (Integer)
Consider the following to establish connectivity between Python and MySQL:
Username: admin
Password: Shopping
Host: localhost
Ans: import pymysql as pm
DB-pm.connect (host="localhost", user="admin", passwd="Shopping", database="Keeper")
MyCursor DB.cursor()
SQL=f"UPDATE SHOP SET QTY=%S WHERE ITEM CODE=%S"% (20,111)
#OR
SQL="UPDATE SHOP SET QTY-20 WHERE ITEM_CODE=111"
MyCursor.execute (SQL)
DB.commit()
OR
(B) (i) Give any two features of SQL.
Ans: (a) It is used to retrieve and view specific data from a table in a database.
(b) It decreases data duplicacy
(ii) Sumit wants to write a code in Python to display all the details of the passengers from the table flight in MySQL database, Travel. The table contains the following attributes:
F_code: Flight code (String)
F_name: Name of flight (String)
Source: Departure city of flight (String)
Destination: Destination city of flight (String)
Consider the following to establish connectivity between Python and MySQL :
Username: root
Password: airplane
Host: localhost
Ans:
import pymysql as pm
DB=pm.connect (host="localhost", user="root",\
password="airplane", database="Travel")
MyCursor DB.cursor()
MyCursor.execute ("SELECT * FROM Flight")
Rec=MyCursor.fetchall ()
for R in Rec:
print (R)