31. MakeInIndia Corporation, an Uttarakhand based IT training company, is planning to set up training centres in various cities in next 2 years. Their first campus is coming up in Kashipur district. At Kashipur campus, they are planning to have 3 different blocks for App development, Web designing and Movie editing. Each block has number of computers, which are required to be connected in a network for communication, data and resource sharing. As a network consultant of this company, you have to suggest the best network related solutions for them for issues/problems raised in question nos. (i) to (v), keeping in mind the distances between various blocks/locations and other given parameters.
Distance between various blocks/locations:
| Block Distance |
Distance |
| App development to Web designing |
28 m |
| App development to Movie editing |
55 m |
| Web designing to Movie editing |
32 m |
| Kashipur Campus to Mussoorie Campus |
232 km |
Number of computers
| Block |
Number of Computers |
| App development |
75 |
| Web designing |
50 |
| Movie editing |
80 |
(i) Suggest the most appropriate block/location to house the SERVER in the Kashipur campus (out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
Ans: Movie editing block is the most appropriate to house the server as it has the maximum number of computers.
(ii) Suggest a device/software to be installed in the Kashipur Campus to take care of data security.
Ans: Firewall
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to economically connect various blocks within the Kashipur Campus.
Ans:
(iv) Suggest the placement of the following devices with appropriate reasons:
a. Switch/Hub; b. Repeater
Ans: Switch/hub will be placed in all blocks to have connectivity within the block.
Repeater is not required between the blocks as the distances are less than 100 mts.
(v) Suggest a protocol that shall be needed to provide Video Conferencing solution between Kashipur Campus and Mussoorie Campus.
Ans: Protocol: VoIP
32. (a) Write the output of the code given below:
p = 5
def sum(q, r=2):
global p
p = r + q**2
print(p, end='#')
a = 10
b = 5
sum(a, b)
sum(r=5, q=1)
Ans: 105#6#
(b) The code given below inserts the following record in the table Student:
RollNo - integer
Name - string
Class - integer
Marks - integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is tiger
The table exists in a MYSQL database named school.
The details (RollNo, Name, Clas and Marks) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 - to form the cursor object
Statement 2 - to execute the command that inserts the record in the table Student.
Statement 3 - to add the record permanently in the database
import mysql.connector as mysql
def sql_data():
con1 = mysql.connect(host="localhost", user="root", password="tiger", database="school")
mycursor = _________________ # Statement 1
rno = int(input("Enter Roll Number :: "))
name = input("Enter name :: ")
clas = int(input("Enter class :: "))
marks = int(input("Enter Marks :: "))
querry = "insert into student values({},'{}',{},{})".format(rno, name, clas, marks)
______________________ # Statement 2
______________________ # Statement 3
print("Data Added successfully")
Ans: Statement 1: con1.cursor()
Statement 2: mycursor.execute(querry)
Statement 3: con1.commit()
OR
(a) Predict the output of the code given below:
s = "welcome2cs"
n = len(s)
m = ""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m + s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '&'
print(m)
Ans: sELCcME&Cc
(b) The code given below reads the following record from the table named student and displays only those records who have marks greater than 75:
RollNo - integer
Name - string
Class - integer
Marks - integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is tiger
The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
Statement 1 - to form the cursor object
Statement 2 - to execute the query that extracts records of those students whose marks are greater than 75.
Statement 3 - to read the complete result of the query (records whose marks are greater than 75) into the object named data, from the table student in the database.
import mysql.connector as mysql
def sql_data():
con1 = mysql.connect(host="localhost", user="root", password="tiger", database="school")
mycursor = _______________ # Statement 1
print("Students with marks greater than 75 are : ")
_________________________ # Statement 2
data = __________________ # Statement 3
for i in data:
print(i)
print()
Ans: Statement 1: con1.cursor()
Statement 2: mycursor.execute("select * from student where Marks>75")
Statement 3: mycursor.fetchall()
33. What is the advantage of using a csv file for permanent storage?
Write a Program in Python that defines and calls the following user defined functions:
(i) ADD () - To accept and add data of an employee to a CSV file ‘record.csv’. Each record consists of a list with field elements as empid, name and mobile to store employee id, employee name and employee salary respectively.
(ii) COUNTR () - To count the number of records present in the CSV file named ‘record.csv’.
Ans: Advantage of a csv file: It is human readable and it can be opened in Excel and Notepad applications. It is just like text file.
Program:
import csv
def ADD():
fout = open("record.csv", "a", newline="\n")
wr = csv.writer(fout)
empid = int(input("Enter Employee id :: "))
name = input("Enter name :: ")
mobile = int(input("Enter mobile number :: "))
lst = [empid, name, mobile] # ---------1/2 mark
wr.writerow(lst) # ---------1/2 mark
fout.close()
def COUNTR():
fin = open("record.csv", "r", newline="\n")
data = csv.reader(fin)
d = list(data)
print(len(d))
fin.close()
ADD()
COUNTR()
OR
Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user defined functions:
(i) add () - To accept and add data of an employee to a CSV file ‘furdata.csv’. Each record consists of a list with field elements as fid, fname and fprice to store furniture id, furniture name and furniture price respectively.
(ii) search () - To display the records of the furniture whose price is more than 10000.