Sol_CS_Pre_Brd_2_2024-25_5thSub.rtf

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

JAYCEES PUBLIC SCHOOL, RUDRAPUR

Pre-Board –2 Class: XII Session: 2024-25


Computer Science (083)-SET-A
Maximum Marks: 70 Time Allowed: 3 hrs
General Instructions:
● This question paper contains 37 questions.
● All questions are compulsory. However, internal choices have been provided in some
questions. Attempt only one of the choices in such questions
● The paper is divided into 5 Sections- A, B, C, D and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of the correct answer should also be written.

Q.No. Section-A (21 x 1 = 21 Marks) Marks


1 State True or False
[1]
““If a loop terminates using break statement, loop else will not execute” True

2 Identify the invalid Python statement from the following.


[1]
a) _b=1 b) __b1= 1 c) b_=1 d) b = _1

3 Consider the string state = “Jharkhand”. Identify the appropriate statement(s)


that will display the last five characters of the string state? [1]
a) state[-5:] b)state[4:] c)state[:4] d)state[:-4]

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

8 Select the correct output of the code:

L1, L2= [10,23,36,45,78], [ ]

for i in range (len(L1)):

L2.insert (i, L1.pop())


[1]
print(L1, L2, sep= ‘@’)

a) [78, 45, 36, 23, 10] @ [ ]


b) [10, 23 ,36 ,45 ,78] @ [78, 45, 36, 23, 10]
c) [10, 23, 36, 45, 78] @ [10, 23, 36, 45, 78]
d) [ ] @ [78, 45, 36, 23, 10]

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)

10 A table ACCOUNTS in a database has 14 columns and 4 records. What is its


degree if 2 more rows are added into the table?
[1]
(a) 14 (b) 16 (c) 6 (d) None of these

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

12 Predict the output of the Python code given below:


value = 50
def display(N):
global value
value = 25
if N%7==0:
value=value+N [1]
else:
value=value-N
print(value, end="#")
display(20)
print(value)

a) 5#50 b) 50#5 c)50#5# d) 5#50#


13 If column “Fees” contains the data set (5000,8000,7500,5000,8000),

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

18 Rearrange the following terms in increasing order of speedy medium of data


transfer.
[1]
Telephone line, Fibre Optics, Coaxial Cable, Twisted Paired Cable
Telephone line → Twisted Pair Cable → Coaxial Cable → Fibre Optics

19 What will the following expression be evaluated to in Python?


[1]
print(2+True) 3

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)

22 What do you mean by type casting? Explain by giving an example. [2]

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.

A) Set the second entry in the list to 17 list.insert(1,17)


OR
B) Add 4,5,6 to the end of the list. list.extend([4,5, 6])

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

(a) W# (b) W#i# (c) W#s# (d) W#i#s#


The code given below accepts a list of integers as an argument and returns
26
the sum of all odd numbers in list. Observe the following code carefully and
rewrite it after removing all syntax and logical errors. Underline all the
corrections made.
def sumeve(L):
S=0
[2]
for K in L:
if K %2 != 0:
S=S+K
return S
L1=[2,3,4,5,6,7]
X= sumeve(L1)
(i)
27
A) Write SQL command to add primary key constraint in the existing
TRAINER table, to make TID as primary key.
ALTER TABLE TRAINER ADD PRIMARY KEY (TID);
OR
B) Write SQL command to remove primary key from table Trainer.
ALTER TABLE Trainer DROP PRIMARY KEY;
(ii)
A) Alok is working in a database named CCA, in which he has created a [2]
table named “DANCE” containing columns danceID, Dancename,
no_of_participants, and category. After creating the table, he realized
that the attribute category has to be deleted from the table.
ALTER TABLE DANCE DROP COLUMN CATEGORY;
OR
B) He wants to add a new attribute TypeCCA of data type string has to be
added. This attribute TypeCCA cannot be left blank.
ALTER TABLE TRAINER ADD(TypeCCA CAHR(10 ) NOT NULL);
28 i. Differentiate between Circuit Switching and Packet Switching.
[2]

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

A) Write a method CountWords() in Python to read data from text file


29 ‘ARTICLE.TXT’ and display the count of words which ends with a
vowel.
def CountWords():
with open('ARTICLE.TXT', 'r') as file:
text = file.read()
words = text.split()
vowels = 'aeiouAEIOU'
count =0
for i in words:
if i[-1] in vowels:
count+=1
print(“Words ending with vowel”, count )

OR [3]

B) A text file “PYTHON.TXT” contains alphanumeric text. Write a


function COPY() that reads this text file and copies only those
lines to another file named “PYTHON1.TXT” which does not ends
with vowel.
def COPY():
f= open(“python.txt”,’r’)
f1= open(“python1.txt”,’r’)
vowels = 'aeiouAEIOU'
for line in f:
if line[-1] not in vowels:
f1.write(line)
f.close()
f1.close()
30 A. A nested list contains the data of visitors in a museum. Each of the [3]
inner lists contains the following data of a visitor:

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.

Consider the table BANK as given below


32
AccNo Cname FD_Amount Months Rate Date
1001 ARTI GUPTA 30000 36 6 2018-07-01
1002 DILIP LAL 50000 48 6.75 2018-03-22
1003 NAVIN GUPTA 30000 36 - 2018-03-01
1004 D.P.YADAV 80000 60 8.25 2017-06-12
1005 JYOTI SHARMA 20000 36 6.50 2017-01-31
1006 RAKESH KUMAR 70000 60 8.25 2018-06-15
1007 K.D.SINGH 50000 48 - 2018-07-05
1008 ANJALI SHARMA 60000 48 6.75 2017-04-02
1009 SWATI GARG 40000 42 6.50 2018-06-15
[4]
1010 RUPINDER KAUR 25000 36 6.50 2018-09-27
A) Write SQL queries for the given statements.
i) Display the detail of all the FD’s having maturity time less than 40
months. SELECT * FROM BANK WHERE Months < 40;
ii) Display the Account Number, customer name and FD amount for
those which do not have number of months 36.
SELECT AccNo, Cname, FD_Amount FROM BANK WHERE Months != 36
iii) Display customer name and FD amount for which the number of
months is 24, 36, 48 or 40.
SELECT Cname, FD_Amount FROM BANK WHERE Months IN (24, 36,

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.

i) addPlayer(name,matches,goals): Name of the player, matches played


and goals scored are passed to the function. The function should append a record
to the csv file.
import csv
def addPlayer(name,matches,goals): [4]
f=open(“Football.csv”, ‘a’, newline=’’)
L=[ name,matches,goals]
W=csv.writer(f, delimiter =’,’)
W.writerow(L)
f.close()
ii) highestGoals(): The function should read the csv file and display the
name of the player with the highest goals.
def highestGoals():
f=open(“Football.csv”, ‘r’, newline=’’)
h=0

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( )

Consider the tables Employees and Departments given below:


34
Table - Employees
Emp_id Ename DOB Gender Salary Dept_id
101 Simer 1994-01-15 F 26000 1
102 Alok 1995-10-18 M 17000 2
103 Hasan 1996-08-21 M 25000 1
104 Kriti 1993-01-12 F 35000 1
105 Gulab 1994-02-20 M 15000 3
106 Jaya 1993-12-01 F 16500 4

Table- Dept_id Dname Location Departments


1 HR GF-005
2 Sales GF-006
3 Analysis SF-204
4 Training FF-102
i) Display the average salary
for male and female employees. [4]
SELECT Gender, AVG(Salary) AS Average_Salary FROM Employees
GROUP BY Gender;
ii) Display the employee name and department name for all
employees in descending order of their salary.
SELECT E.Ename, D.Dname FROM Employees E, Departments D
where E.Dept_id = D.Dept_id ORDER BY E.Salary DESC;
iii) Display the maximum salary of employees born after 31
December 1995.
SELECT MAX(Salary) FROM Employees WHERE DOB > '1995-12-31';
iv) A) Display the department id and number of employees for all
departments having more than 1 employee.
SELECT Dept_id, COUNT(Emp_id) FROM Employees GROUP BY
Dept_id HAVING COUNT(Emp_id) > 1;
OR
C) Display employee names of HR department along with their
salaries.
SELECT E.Ename, E.Salary FROM Employees E, Departments D
where E.Dept_id = D.Dept_id and D.Dname = 'HR';
11/13
Shivaji has created a table named Game in MYSQL database Sports
35 containing following attributes:
• GID (Game ID)-integer
• Gname( Game name)-varchar
• No_of_Participants (number of participants)- integer
Note the following to stablish connectivity between Python and MySQL:
• Username: root
• Password: JPS@123
• Host: localhost
Write the following Python function to perform the specified operation:
(i) change(): To modify the game name Tennis to Table tennis.
(ii) display(gname): to read the data from database and display the no of
participants of the game entered by user which is passed to the function as
parameter.
import mysql.connector as mm
db=mm.connect(host=’localhost’,user=’root’,passwd=’JPS@123’)
[4]
mycur=db.cursor()
mycur.execute(‘USE Sports’)

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 ()

The file EMP.DAT contains student information in following form–


EMP_ID – Employee ID- integer –
EMP_Name – Name of Employee- string –
EMP_Desig- Designation of Employee– string –
Exp- Experience in years – integer
You, as a programmer of the company, have been assigned to do this job
for Sanjana.
Expertia Professional Global (EPG) is an online corporate training provider
31 company for IT related courses. The company is setting up their new
campus in Mumbai. You as a network expert must study the physical
locations of various buildings and the number of computers to be installed.
In the planning phase, provide the best possible answers for the queries (i)
to (v) raised by them.

13/13
[5]Bravo

Centre to centre distances between various blocks is as follows:

i) Suggest the most suitable place (i.e., Block/Centre) to install the


server of this University with a suitable reason.
Bravo Block having maximum number of computers
ii) Suggest a layout for connecting these blocks for a wired
connectivity.

iii) Suggest the placement of Switches and Modem in the blocks


Switch to be placed in each block to connect computers within
the block. Modem can be placed with server at Bravo Block
iv) Suggest the placement of a Repeater in the network with
justification.
In suggested layout there is no need of repeater as maximum
distance between blocks is 80 mt. But if Bravo to Alpha or
Bravo to Delta are connected a repeater each will be required
between them.
v) A) The company wants to provide a remote research institute 5km from the main
campus. Which type of communication link will provide the fastest link from main
campus to the remote campus? Deploy fiber-optic cables as they
offer the fastest and most reliable communication link between
the main campus and the remote research institute.

14/13
OR
B) What type of network (PAN, LAN, MAN, or WAN) will be set up
between main campus and remote campus? MAN

(ALL THE BEST)

15/13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy