Cs Paper-1
Cs Paper-1
Cs Paper-1
191 | P a g e
Reason (R): In text file, there is no delimiter for a line.
SECTION-B
19 Identify the errors in the program segment given below. Rewrite the corrected code 2
and underline each correction.
def Tot (Number):
Sum=0
for C in RANGE (1, Number + 1):
Sum + = C
return Sum
print(Tot [3])
print(Tot[6])
20 Write two points of difference between HTTP and FTP. 2
OR
State the advantages and disadvantages of star topology over bus topology?
21 What will be the output of the following Python code? 2
d1={“a”:10, “b”=2, “c”:3}
str1= “ ”
for i in d1:
str1=str1+str(d1[i])+ “ ”
str2=str1[ : -1]
print(str2[: : -1])
22 What do you understand by Candidate keys in a table? Give a suitable example of 2
candidate keys from a table containing some meaningful data.
23 (i) Write the full forms of the following: 2
(a) SMTP (b) IPR
(ii) Which protocol is used in creating a connection with a remote machine?
24 What possible output(s) are expected to be displayed on screen at the time of execution 2
of the following code? Also specify the maximum and minimum value that can be
assigned to variable X.
import random
L=[10,7,21]
192 | P a g e
X=random.randint(1,2)
for i in range(X):
Y=random.randint(1,X)
print(L[Y],”$”,end=” ”)
OR
25 Differentiate between Drop and Delete commands of MYSQL. Write its syntax. 2
OR
For a table “Company” having column cno, cname, department and salary, write the SQL
statement to display average salary of each department.
SECTION – C
26 Consider the following tables:
193 | P a g e
(i) Write any one point of difference between Equi join and Natural join.
(ii) Find output:
(a) select *from product p, supplier s where p.supid=s.supid;
(b) select *from product natural join supplier; 1
OR 2
194 | P a g e
27 A text file “Quotes .Txt” has the following data written in it: 3
Living a life you can be proud of
Doing your best
Spending your time with people and activities that are important to you
Standing up for things that are right even when it’s hard
Becoming the best version of you
Write a user defined function to display the total number of words present in the file.
OR
Write a function in Python to count the number of lines in a text file ‘STORY.TXT’
which is starting with an alphabet ‘A’.
28. (i) Write the actual datatypes as per the following Structure requirement during 2
creation of a table:
(ii) Vani created a table named Customer that have fields Cno, Custname, Address,
Amount. Now she wants to increase the width to 30 Characters of the column 1
“Address”. Write the SQL command for it.
29 Write a function INDEX_LIST(L), where L is the list of elements passed as argument 3
to the function. The function returns another list named ‘indexList’ that stores the
indices of all Non-Zero Elements of L. For example: If L contains [12,4,0,11,0,56] The
indexList will have - [0,1,3,5]
30 Write a function in python, Push(Package) and Pop(Package) to add details of 3
employee contain information (Empid, Ename and Salary) in the form of tuple in
Package and delete a Package from a List of Package Description, considering them to
act as push and pop operations of the Stack data structure.
OR
Jiya has a list containing 8 integers. You need to help her create a program with two
user defined functions to perform the following operations based on this list.
• Traverse the content of the list and push those numbers into a stack which are
divisible by both 5 and 3.
• Pop and display the content of the stack.
195 | P a g e
For example: If the sample Content of the list is as follows:
L=[5,15,21,30,45,50,60,75] Sample Output of the code should be: 75 60 45 30 15
SECTION D
31 Alpha Pvt Ltd is setting up the network in Chennai. There are four blocks- Block A, 5
Block B, Block C & Block D.
i)Suggest the most suitable block to place the server with a suitable reason.
ii) Suggest the cable layout for connections between the various blocks.
iii) Suggest the placement of following devices with justification:
(a) Switch/Hub (b) Repeater
196 | P a g e
iv)The organization is planning to link its front office situated in the city in a hilly
region where cable connection is not possible. Suggest an economic way to connect
with reasonably high speed.
v) Out of following which type of Network it is LAN,MAN,WAN
32 (i) Find and write the output of the following Python code: 2
data=["P",20,"R",10,"S",30]
times=0
alpha=" "
add=0
for c in range(1,6,2):
times = times + c
alpha = alpha + data [c-1] + "$"
add = add + data[c]
print (times, add, alpha)
(ii) The given program is used to connect with MySQL abd show the name of the all
the record from the table “stmaster” from the database “oraclenk”. Write the missing 3
statements to complete the code.
import _____.connector_______ pymysql
dbcon=pymysql._____________(host=”localhost”, user=”root”,
________=”sia@1928”,database=” oraclenk”)
if dbcon.isconnected()==False:
print(“Error in establishing connection:”)
cur=dbcon.______________()
query= “select * from stmaster”
cur.execute(_________)
resultset=cur.fetchmany(3)
for row in resultset:
print(row)
dbcon.______()
197 | P a g e
OR
(i) Consider the program given below and justify the output.
c = 10
2
def add():
global c
c=c+2
print("Inside add():", c)
add()
c=15
print("In main:", c)
Output:
Inside add() : 12
In main: 15
(ii) Avni is trying to connect Python with MySQL for her project. Help her to write the
python statement on the following:-
(i) Name the library, which should be imported to connect MySQL with Python.
(ii) Name the function, used to run SQL query in Python. 3
(iii) Write Python statement of connect function having the arguments values as :
Host name :192.168.11.111
User : root
Password: Admin
Database : MYPROJECT
198 | P a g e
33 (i) Differentiate between the writerow and writerows function. 2
(ii) 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 3
‘EMPLOYEE.CSV’. Each record consists of a list with field elements
as EId, EName and EPrice 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
OR
(i) State the difference between seek() and tell() functions of Python.
(ii) 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. 2
(ii) COUNTR() – To count the number of records present in the CSV file
named ‘record.csv’. 3
SECTION-E
34 Consider the table MobileMaster 4
M_Id M_Company M_Name M_Price M_Mf_Date
MB001 Samsung Galaxy 13000 2014-02-12
MB002 Nokia N1100 7500 2011-04-15
MB003 Realme C35 12000 2021-11-20
MB004 Oppo SelfieEx 12500 2015-08-21
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered as Primary
key.
(ii) If two columns are added and 2 rows are deleted from the table result, what
will be the new degree and cardinality of the above table?
(iii) Write the statements to:
a. To display details of those mobiles whose price isgreater than 8000.
b. Increase the M_Price of all mobiles manufactured after 2015-01-01 by 500.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of mobileshaving price less than 8000.
b. Add a column REMARKS in the table with datatype as varchar with 50
characters
199 | P a g e
35 Alia has written a code and created a binary file EMPLOYEE.DAT with employeeid, 4
ename and salary. The file contains 10 records. He now has to update a record based
on the employee id entered by the user and update the salary. The updated record is
then to be written in the file updateemp.dat. The records which are not to be updated
also have to be written to the file updateemp.dat. If the employee id is not found, an
appropriate message should be displayed. As a Python expert, help him to complete the
following code based on the requirement given above:
import _______ #Statement 1
def update_data():
rec={}
fin=open("EMPLOYEE.DAT","rb")
fout=open("_____________") #Statement 2
found=False
eid=int(input("Enter employee id to update their salary :: "))
while True:
try:
rec=______________ #Statement 3
if rec["employeeid"]==eid:
found=True
rec["salary"]=int(input("Enter new salary :: "))
pickle.____________ #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has been updated.")
else:
print("No employee with such id is not found")
fin.close()
fout.close()
(i) Which module should be imported in the program? (Statement 1)
200 | P a g e
(ii) Write the correct statement required to open a temporary file named
updateemp.dat. (Statement 2)
(iii) Which statement should Alia fill in Statement 3 to read the data from the
binary file, EMPLOYEE.DAT and in Statement 4 to write the updated data
in the file, updateemp.dat?
201 | P a g e