Crohihiho
Crohihiho
Page.1
8. What will be the output of the following code snippet? [1]
t1 = (1, (2, (3, (4,))))
t2=t1
t1 += (5,)
print(t1)
(a) (1, (2, (3, (4,)),5))] b) (1, (2, (3, (4,)))(5,) (c) (1, (2, (3, (4,))), 5) (d) (5,) (c)
9. Consider the following code and justify the output if it executes without error, if not [1]
specify the name of the error.
L=[1,2,3]
T=('a','b','c')
L+=T
print(L) [1, 2, 3, 'a', 'b', 'c']
10. What will be the output of the following code? [1]
d = 31
def addsym():
global d
d = d + 20
print(d,end='##')
addsym()
d=45
print(d,end='$$')
(a) 51#45$$ (b) 51##45$$ (c) 45##51$$ (d) 51$$45## (b)
11. Regarding exception handling, how many except blocks can a try block have? [1]
(a) 1 (b) >=0 (c) 2 (d) no such block exists. (b)
12. Which of the following commands is not a DDL command? [1]
(a) DROP (b) DELETE (c) CREATE (d) ALTER (b)
13. What will be the output of the following code? [1]
import pickle data = {1: "One", 2: "Two", 3: "Three"}
with open("sample.bin", "wb") as f:
pickle.dump(data, f)
with open("sample.bin", "rb") as f:
result = pickle.load(f)
print(result)
(a) {1: "One", 2: "Two", 3: "Three"} (b) [1: "One", 2: "Two", 3: "Three"]
(c) "{1: 'One', 2: 'Two', 3: 'Three'}" (d) SyntaxError (a)
14. What is the main characteristic of a peer-to-peer (P2P) network? [1]
(a) It uses a central server to manage the network.
(b) All devices act as both clients and servers.
(c) It is a wide area network (WAN).
(d) It supports only wired connections. (b)
15. Which of the following network topologies is most commonly used in modern office [1]
environments for connecting a large number of computers?
(a) Star Topology (b) Ring Topology (c) Bus Topology (d) Mesh Topology (a)
16. What is the main limitation of using copper cables (e.g., twisted pair cables) in wired [1]
communication systems?
a) They are expensive and hard to install.
b) They are prone to interference and signal degradation over long distances.
c) They require complex technology for data transmission.
d) They provide low bandwidth compared to fiber-optic cables. (b)
17. Hub decreases the traffic in the network whereas switch increases the traffic in the network. [1]
(Ture/False) False
18. aggregate function can be used to find the cardinality of a table. count(*)/count() [1]
Page.2
19. Table A has 4 rows and 3 columns, Table B has 2 rows and 5 columns, and Table C has 6 [1]
rows and 2 columns. What is the degree and cardinality of the resulting table after
performing a Cartesian product between all three tables?
a) Degree = 10, Cardinality = 48 b) Degree = 12, Cardinality = 48
c) Degree = 12, Cardinality = 36 d) Degree = 8, Cardinality = 72 (a)
Q20 and 21 are ASSERTION AND REASONING based questions. 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
20. Assertion (A): DROP command in SQL is DDL command. [1]
Reasoning (R): DROP and DELETE are used to delete rows and columns, therefore, these
can be used interchangeably. (c)
21. Assertion (A): A function in Python can return multiple values. [1]
Reasoning (R): In Python, a function returns multiple values as a list. (c)
SECTION – B ( 7 x 2=14 Marks)
22. Mithilesh has written a code to input a number and evaluate its factorial and then finally print [2]
the result in the format: “The factorial of the <number> is <factorial value>”. His code is
having errors. Rewrite the correct code and underline the corrections made.
f=0 f=1
num = input("Enter a number whose factorial you want to evaluate :") int
n = num
while num > 1:
f = f * num
num -= 1
else: indentation
print("The factorial of : ", num , "is" , f) print("The factorial of : ", n , "is" , f)
23. Given Empdict={"Eno": "E001","Ename":"Jack", "Dept":"Accts"} [2]
(I) (a) Write a statement to add the salary as 15000 into the dictionary.
(OR)
(b) Write a statement to modify the "Ename" to "Ananya".
(II)
(a) Write a statement to display the keys of the dictionary.
(OR)
(b) Write a statement to remove the key: value pair of "Dept"
(I) a) Empdict[‘Salary’]=15000
(OR)
(b) Empdict[“Ename”]=”Ananya”
Page.3
25. What possible outputs(s) will be obtained when the following code is executed? What is the [2]
possible minimum and maximum value T can take?
import random
List = ['CTC', 'BBSR', 'KDML', 'PURI']
T= 5 + random.randint(1,6)
for y in range (4):
x = random.randint (1,3)
print (List[x], end = '#')
a) KDML#PURI#BBSR#CTC# b) KDML#KDML#PURI#PURI#
c) BBSR#KDML#BBSR#KDML# d) All of these 3 options are possible
Max= 11, Min = 6 b), c)
26. (i) [2]
(a) What constraint/s should be applied to the column in a table to make it an alternate key?
OR UNIQUE ,NOT NULL
(b) What constraint should be applied on a column of a table so that it becomes compulsory
to insert the value ? NOT NULL (PRIMARY KEY CAN BE GIVEN MARK)
(ii)
(a) Write an SQL command to assign F_id as primary key in the table named flight.
OR
ALTER TABLE flight ADD PRIMARY KEY(F_id);
(b) Write an SQL command to remove the column remarks from the table name
customer. ALTER TABLE CUSTOMER DROP REMARKS;
27. Identify Primary Key and Candidate Key present if any in the table below name Colleges. [2]
Justify.
Page.4
29. (a) Write a function countwords( ) that reads a text file “story.txt” and display only unique [3]
words from the file.
Example.
If the file story.txt contains the following:
“he is a good boy and he is also good by behaviour”
Then the output should be
a boy and also by behaviour
OR
(b) Write a function that reads a text file “diary.txt” and display the list of words that start
with a lowercase vowel and list of words that start with a uppercase vowel separately.
Example:
If the file diary.txt contains the following:
A quick black Elephant enters into a jungle.
Then the output should be
List of words starting with lowercase vowels: [“enters”, “into”, “a”]
List of words starting with uppercase vowels : [ “A”, “Elephant”]
a)
OR
b)
Page.5
30. (a) Rakshana has created a dictionary “Garment” storing data of garments items. Write [3]
functions for the following.
Pushitems() – the dictionary should be passed as parameter. The function should checks
the details in the dictionary and pushes only the garment into a stack whose price is above
5000.
Popitem( ) – function to check stack emptiness, if it is not empty remove an item from the
stack and display the remaining stack.
The structure of the dictionary is given below.
Garment = {‘1’:[‘shirt’,6500], ‘2’:[‘trouser’,2000], ‘3’:[‘coat’, 15000]}
OR
(b) John is assigned to write a program that inputs many numbers and stores only the
perfect numbers into a stack named perfectstack[ ].
He has define the following functions for the purpose. Help him to complete the task.
Push-perfect( ) – to push the perfect numbers into the stack.
Pop-perfect( ) – to check the stack emptiness and pop an element from the stack if it is
not empty and display the remaining stack.
Garment = {'1':['shirt',6500], '2':['trouser',2000], '3':['coat', 15000]}
s=[]
def Pushitems(Garment): push function carries 1 mark
for i in Garment.values():
if i[1]>=5000:
s.append(i)
def Popitems(): pop function carries 1 mark
print(s)
if s==[]:
print("empty")
else:
s.pop()
x=len(s)-1 display carries 1 mark
while x>=0:
print(s[x])
x=x-1
OR
perfectstack = []
def pushperfect(n): push function carries 1 mark
sum=0
for i in range(1,n):
if n%i==0:
sum += i
if sum == n:
perfectstack.append(n)
def popperfect( ): pop function carries 1 mark
if perfectstack == []:
print("Stack empty")
else:
a=perfectstack.pop()
print("element deleted=",a) ans='y'
x=len(perfectstack)-1 while ans=='y':
while x>=0: n=int(input("Enter a number"))
print(perfectstack[x]) pushperfect(n) ½ mark each call
x-=1 ans=input(" continue?")
Page.6 popperfect()
31. Predict the output of the following code snippet: [3]
(i) Numbers=[9,18,27,36]
for Num in Numbers:
for N in range(1,Num%8): 1#
print(N,"#",end="") 1#2#
print() 1#2#3#
(ii) d = {"can": 25, "ban": 48, "van": 83, “man”: 22}
str1 = ""
for key in d:
if key!="ban":
str1 = str1 + str(d[key]) + "@" + "\n" 25@
str2 = str1[:-1] 83@
print(str2) 22@
SECTION – D ( 4 x 4 = 16 Marks)
32. Write SQL queries for (i)to(iv), which are based on the table: PRODUCT given below: [4]
Page.7
a)
Count(distinct type)
Fiction
Literature
Comic
b)
TYPE COUNT(*)
Fiction 2
Literature 1
Comic 2
c)
BNAME
German Easy
d)
BNO BNAME TYPE
C101 TARZAN IN THE LOST WORLD COMIC
33. A csv file "country.csv" contains the data of a survey. Each record of the file contains the [4]
following data:
● Name of a country
● Population of the country
● Sample Size (Number of persons who participated in the survey in that country)
● working (Number of persons who are working)
Write the following Python functions to perform the specified operations on this file:
(i) Read all the data from the file in the form of a list and display all those records for
which the population is more than 5000000.
(ii) Count the number of records in the file.
import csv
def search():
obj=open("country.csv","r",newline="")
data=csv.reader(obj)
for i in data:
if i[1] >=5000000:
print(i)
obj.close()
search()
def CountRec():
obj=open("country.csv","r",newline="")
data=csv.reader(obj)
c=0
for i in data:
c=c+1
print("The number ofd records:",c)
obj.close()
CountRec()
Page.8
34. Shekhar has been entrusted with the management of Law University Database. He needs to [4]
access some information from FACULTY and COURSES tables for a survey analysis.
Help him extract the following information by writing the desired SQL queries as
mentioned below.
Table: FACULTY
Table: COURSES
(i) To display complete details (from both the tables) of those Faculties whose salary is
less than 12000.
(ii) To display the details of Courses whose fees is in the range of 20000 to 50000 (both
values included)
(iii) To increase the fees of all courses by 500 which have “Computer” in their Course
names.
(iv) (A) To display names (FName and LName) of Faculty taking System Design.
OR
(B) To display the cartesian product of these two tables.
(i) select * from faculty, courses where faculty.f_id=courses.f_id and salary<12000;
(ii) select * from courses where fees between 20000 and 50000;
(iii) update courses set fees=fees+500 where cname like “%computer%”;
(iv) (A) select fname,lname from faculty,courses where faculty.f_id=courses.f_id and
cname=’system design’;
(OR) (B) select * from faculty,courses;
Page.9
35. Given the following table : Collegestuds [4]
Write the Python code to update grade to “A” for all these students who are getting more
than 8 as points and update grade to “B” for rest of the students.
Assume Database = college, Password = student, user name = admin , host = localhost
SECTION – E (2 X 5 = 10 Marks)
36. a) Which file can be opened with notepad as well as MS Excel? [1]
b) A binary file “Garment.dat” exists containing records of different types of garments as
per the following structure: [4]
GID Type Gender Cost.
Write a python program to add and search records of garments from the binary file and
display using the following functions:
Addgarment( ) – function to input details of garments and store them to the file
“Garment.dat”, if the garment type is “cotton” or “silk”
Showgarment( ) – To read and display the records of “Silk” type and also display the
count of the records displayed.
(a) csv file
Page.10
37. The government has planned to develop digital awareness in the rural areas (5) of the [5]
nation. According to the plan, an initiative is taken to set up Digital Training Centers in
villages across the country with its Head office in the nearest cities. The committee has
hired a networking consultancy to create a model of the network in which each City Head
office is connected to the Training Centers situated in 3 nearby villages. As a network
expert in the consultancy, you have to suggest the best network-related solutions for the
issues/problems raised in (a) to (e), keeping in mind the distance between various locations
and other given parameters.
(c) Which hardware networking device, will you suggest to connect all the computers
within the premises of every Village Training Center ? Hub/switch
(d) To ensure that the employees in all departments can communicate with each other and
share data seamlessly for wired LAN, what type of connection should be established
between different floors? Ethernet cables
(e) Which protocol would be the most efficient for secure email communications within the
Village Training Centers? SMTP
Page.11