Sol_CS_Pre_Brd_2_2024-25_5thSub.rtf
Sol_CS_Pre_Brd_2_2024-25_5thSub.rtf
Sol_CS_Pre_Brd_2_2024-25_5thSub.rtf
4 If x=10, y=20, z=30 then write the output of following python statement.
[1]
print(z-y/x+int(x/z)) 28.0
5 Consider the following statements and choose the correct output from the
given options :
EXAM="COMPUTER SCIENCE" [1]
print(EXAM[:12:-2])
a) EN b) CI c)SCIENCE d) ENCE
1/13
6 Q.6. What will be the output of the following python dictionary
operation?
data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)
[1]
a) {'A':2000, 'B':2500, 'C':3000, 'A':4000}
b) {'A':2000, 'B':2500, 'C':3000}
c) {'A':4000, 'B':2500, 'C':3000}
d) It will generate an error.
If a List is created as l1 = [1,2,3,4,5] then following statement is
7
executed-
l1.append([5,6,[7,8,[9,10]]])
Then what will be the final length of l1?
[1]
a) 10 b) 5 c) 6 d) Error
9 To move a file pointer 20 bytes ahead from the beginning of file which one of
the following is correct. [1]
a) seek(1,20) b) seek(20,0) c) seek(0,20) d) seek(20,1)
2/13
What will happen if an exception is raised inside the try block and there is no
11
corresponding except block to handle it?
a) The program will terminate
[1]
b) The exception will be ignored
c) The program will enter an infinite loop
d) The program will continue executing the code after the try-except block
what will be the output after the execution of the given query?
[1]
SELECT SUM (DISTINCT Fees) FROM student;
(a) 20500 (b) 10000 (c) 20000 (d) 33500
Which of the following query is incorrect? Assume table EMPLOYEE with
14
attributes
EMPCODE, NAME, SALARY and CITY.
[1]
a) select count(*) from employee; b) select count(name) from employee;
c) select avg(salary) from employee; d) select mean(salary) from employee;
15 The statement which is used to get the number of rows fetched by execute()
method of cursor:
[1]
a) cursor.rowcount() b) cursor.rowscount()
c) cursor.rows() d) cursor.rowcount
3/13
16 Which SQL command is used to change some values in existing rows?
[1]
a) update b) insert c) alter d) order
17 Identify the device on the network which is responsible for storing MAC address
of the machine. [1]
a) NIC b) Router c) RJ45 d) Repeater
Q 20 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): A SELECT command in SQL can have both WHERE and
HAVING clauses.
Reasoning (R): WHERE and HAVING clauses are used to check [1]
conditions, therefore, these can be used interchangeably.
(c) A is True but R is False
21 Assertion (A):- open() is a built in method of python, used for handling data files.
Reason (R):- open() method is used to open a file in Python and it returns a file
object called file handle. The file handle is used to transfer data to and from the file [1]
by calling the functions defined in Python’s io modules.
(a) Both A and R are true and R is the correct explanation for A
Q No Marks
Section-B ( 7 x 2=14 Marks)
4/13
Type casting in Python refers to the process of converting a
variable from one data type to another. This is useful when
we need to perform operations or functions that require a
specific data type. Python provides built-in functions for
type casting.
Type casting can be implicit or explicit:
Implicit: Python automatically converts compatible types
(e.g., int to float during arithmetic operations).
Explicit: You manually convert using type casting functions
(e.g., int(), float()).
For example-
# Original float value
num = 10.5
# Casting to integer
int_num = int(num)
print("Original value:", num) # Output: 10.5
print("After type casting:", int_num) # Output: 10
Briefly describe any two literals in python.
23
In Python, literals are fixed values assigned to variables
or constants directly in the code. They represent data that
does not change.
1. String Literals:
String literals are sequences of characters enclosed in
single quotes ('), double quotes ("), or triple quotes ('''
or """). # Single-quoted string literal
single_quote = 'Hello'
[2]
# Double-quoted string literal
double_quote = "World"
2. Numeric Literals:
Numeric literals represent numbers and are classified into
three types:
Integer literals: Whole numbers (e.g., 10, -5).
Floating-point literals: Decimal numbers (e.g., 3.14,)
Complex literals: Numbers with real and imaginary parts
(e.g., 3 + 4j).
(i) A) Consider the list List=[6,7,8,9]. What will be the output of following
24
operations on List:
a) List*2 b) List *=2
[6, 7, 8, 9, 6, 7, 8, 9] [6, 7, 8, 9, 6, 7, 8, 9]
OR
B) Given a list l=[13,14,15,112,125.7,[12,11,10,15],188]
write python statements to generate the given output.
[14,112, [12,11,10,15]] print(l[1::2]) or print(l[1:6:2]) [2]
(ii) Start with a list [8,9,10]. Do the following with the list functions.
5/13
25 What possible output(s) are expected to be displayed on screen at the time
of execution of the program from the following code? Also specify the
minimum and maximum possible values of the variable b.
import random
a="Wisdom"
[2]
b=random.randint(1,6)
for i in range(0,b,2):
print(a[i],end='#') Min,Max=1, 6
6/13
OR
ii. Give names of any 2 Server Side Scripting languages.
ACTIVE Server Page, JAVA Server Page, PHP
Q.No. Section-C ( 3 x 3 = 9 Marks) Marks
OR [3]
7/13
[V_no (int), Date (string), Name (string), Gender (String
M/F), Age (int)]
Write the following user defined functions to perform given operations
on the stack named "status":
(i) Push_element(Visitors) - To Push an object containing Gender of
visitor who are in the age range of 15 to 20.
Stack=[ ]
def Push_element(Visitors):
for i in Visitors:
if i[4]>=15 and i[4]<=20:
Stack.append( i[3])
(ii) Peek_element() – To display the topmost element from the stack, if it
has at least one element, otherwise print no element.
def Peek_element():
if stack!=[ ]:
print(stack[-1] )
else:
print(“no element”)
(iii) Pop_element() - To Pop the objects from the stack and count and
display the number of Male and Female entries in the stack. Also,
display “Done” when there are no elements in the stack.
def Pop_element():
m,f=0,0
while True
if stack![ ]:
if I in ‘M’;
m+=1
else:
f+=1
else:
break
print(‘Female:’ f)
print(‘Male:’ m)
print(‘Done’)
OR
B. Write a function in Python, Push(EventDetails) where , EventDetails
is a dictionary containing the number of persons attending the
events– {EventName : NumberOfPersons}. The function should push
the names of those events in the stack named ‘BigEvents’ which have
number of persons greater than 200. Also display the count of
elements pushed on to the stack.
BigEvents=[ ]
def Push(EventDetails):
count=0
for i in EventDetails:
for j in i:
if i [ j ]>200:
8/13
BigEvents.append( j )
count+=1
print(‘The count of elements in the stack is’, count)
Write Give the output of following.Q.31.
31 s="PREboardCS*2024!"
j=2
for i in s.split('*'):
k = i [ : j ]
if k.isupper():
j=j+1 [3]
elif k.isdigit():
j=j+2
else:
j=j+3
print(s [ j : : j ] ,k, sep='@')
brS0!@PR
a*!@202
Section-D ( 4 x 4 = 16 Marks) Marks
Q.No.
9/13
48, 40);
iv) Display the average FD amount from the table with heading
“Average FD Amount”
SELECT AVG(FD_Amount) AS "Average FD Amount" FROM BANK;
OR
B) Write the outputs based on the given queries.
i) Select sum(FD_Amount) from Bank where Date like ‘2018%’;
sum(FD_Amount) 295000
ii) Select Cname,FD_Amount from Bank where FD_Amount <500000
and Rate >7.00;
Cname FD_Amount
------------------------------
D.P.YADAV 80000
RAKESH KUMAR 70000
K.D. SINGH 50000
iii) Select distinct (Months) from Bank;
Months
-------------------
36
48
60
42
iv) Select Cname from Bank where FD_Amount between(70000 and 80000);
Cname
D.P.YADAV
RAKESH KUMAR
33 Q.33. Vijay has created a csv file “Football.csv” to store player name,
matches and goals scored. Help him to write the following functions to
perform the given task.
10/13
name’’
r=csv.reader(f, delimiter=’,’)
for rec in r:
if rec[2]>h:
h=rec[2]
name=rec[0]
print(‘player with the highest goals’, name)
f.close( )
def change():
q=”Update Game set Gname=’Tennis’ where Gname=’Table
Tennis’”
mycur.execute(q)
db.commit()
def display(gname):
q=”Select count(No_of_Participants)from Game where Gname=
‘{}’”.format(gname)
mycur.execute(q)
data=mycur.fetchall()
for rec in data:
print(rec)
Q.No SECTION E (2 X 5 = 10 Marks) Marks
Sanjana is an HR manager working in a company. She needs to manage
36
the records of various candidates. She has to store information of
employees, and she wants to store data in a binary file name EMP.DAT, with
the help of following user defined functions -
(I) Write a function to input the data of a candidate and append it in the
binary file.
import pickle
def Add_Data( ):
f= open(‘EMP.DAT’, ‘ab’)
[5]
ID= int(input(‘Enter ID’))
N= input(‘Enter name’)
D= input(‘Endter Designation’)
E= int(input(‘Experience in Years))
L=[ID,N,D,E]
pickle.dump(L,f)
f.cloe()
(II) Write a function to update the data of candidates whose experience
is more than 10 years and change their designation to "Senior Manager".
12/13
def Update_Data():
f= open(‘EMP.DAT’, ‘rb’)
L=[]
try:
while True:
rec=pickle.load(f)
if rec[3]>10:
rec[2]=’Senior Manager’
L.append(rec)
except:
f.close()
f= open(‘EMP.DAT’, ‘wb’)
for rec in L:
pickle.dump(rec)
f.close()
(III) Write a function to read the data from the binary file and display the
data of all those candidates who are not "Senior Manager".
def Display_Data():
f= open(‘EMP.DAT’, ‘rb’)
L=0
try:
while True:
rec=pickle.load(f)
if rec[2]! =’Senior Manager’:
print(rec)
L=1
except:
if L==0:
print(‘No Such Record’)
f.close ()
13/13
[5]Bravo
14/13
OR
B) What type of network (PAN, LAN, MAN, or WAN) will be set up
between main campus and remote campus? MAN
15/13