cs pb1 ms

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

केन्द्रीय विद्यालय संगठन, बेंगलुरु क्षेत्र

KENDRIYA VIDYALAYA SANGATHAN , BENGALURU REGION


प्रथम प्री बोर्ड परीक्षा – 2024-25
FIRST PRE BOARD EXAMINATION – 2024-25
CLASS XII Maximum Marks: 70
SUBJECT: Computer Science (083) TIME: 3 HOURS

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.

SECTION A – 1 MARKS
1 State True or False 1
A user defined function in python can return more than one values.
Ans 1 True
2 Identify the output of the following code 1
print(True and 5>9 or not 4==4)
A) True
B) False
C) Error
D) None
Ans 2 B) False
3 What is the output of the following code 1
rem="how are you"
n=rem.find('Re')
print(n)
A) -1
B) 5
C) 6
D) Error
Ans 3 A) -1
4 What is the output of the following code 1
exam="IN the Year2025"
s1=exam[4:6].upper()
s2=exam[7:9]
s3=exam[-3:-6:-1]
print(s1,s2,s3)
A) THE Y 02
B) HE YE 02R
C) HE ye 02
D) HE Ye 02r
Ans 4 D) HE Ye 02r
5 What will be the output of the following code? 1
subject="INFORMATICS PRACTICES"
res=subject[-2:-12:-3]
print(res)
A) ECIT
B) ETRS
C) FORM
D) EIAP
Ans 5 B) ETRS
6 What will be the output of the following code? 1
t1=(2,4)
t2=(10,20,40,50)
res=t1[1]+t2[1:3]
print(res)
A) (4,20,40)
B) 4,20,40
C) None
D) Error
Ans 6 D) Error
7 Identify the output of the following Python statements. 1
color={1:"red",2:"blue",3:"orange",4:"blue"}
print(color.popitem())
A) (4, 'blue')
B) [4, 'blue']
C) 4
D) None of the above
Ans 7 A) (4, 'blue')
8 Identify the output of the following Python statements. 1
lst1 = [50, 165, 99, 77, 100,46]
lst1.insert( 2, 44)
lst1.insert( 5, 200)
print (lst1[-3])
A) 100
B) 46
C) 200
D) 99
Ans 8 C) 200
9 The table1 has attribute C1,C2,C3,C4,C5 of which C1 is primary key and C2,C4 are 1
alternate key. Find candidate keys.
A) C5, C7, C1
B) C1,C2,C4
C) C3,C5
D) C2,C4,C3,C5
Ans 9 B) C1,C2,C4
10 Somu is trying to write a tuple tup1 = (1,2,3,4,5) on a binary file hello.bin. Consider 1
the following code written by him.

import pickle
tup1 = (1,2,3,4,5)
myfile = open("test.bin",'wb')
pickle._______ #Statement 1
myfile.close()

Identify the missing code in Statement 1.


A) dump(myfile,tup1)
B) dump(tup1, myfile)
C) write(tup1,myfile)
D) load(myfile,tup1)
Ans B) dump(tup1, myfile)
10
11 For what value of a,b it display the output as HELLO. 1
try:
res=a/b
print("HI")
except :
print("HELLO")
A) a=0, b= 10
B) a=5, b=10
C) a=10, b=0
D) a=100, b=10
Ans C) a=10, b=0
11
12 What will be the output of the following code ? 1
bg = 50
def display(N):
global bg
bg = 125
if N%5>2:
bg = bg + N
else:
bg = bg - N
print(bg, end="*")
display(59)
print(bg)
A)50*
B)50*59
C)125*184
D)50*184
Ans D)50*184
12
13 Which SQL command is used to modify the contents in the table ? 1
A) SELECT
B) DELETE
C) UPDATE
D) DROP
Ans C) UPDATE
13
14 Which parameter is optional to establish a connection between Python and SQL 1
database using connect() ?
A) host
B) database
C) user
D) password
Ans C) Database
14
15 In a relational model, tables are called _________, that store data for different 1
columns.
A) Attributes
B) Degrees
C) Tuples
D) Relations
Ans D) Relations
15
16 Which query displays the actual number of values present in the column ADDRESS 1
of table TEACHER having a few null values in it?
A) select count(*) from teacher;
B) select count(addr) from teacher;
C) select count(address) from teacher;
D) select * from teacher;
Ans C) select count(address) from teacher;
16
17 Which communication methodology is designed to deliver both voice and 1
multimedia communications over Internet protocol.
A) VoIP
B) SMTP
C) PPP
D) HTTP
Ans A) VOIP
17
18 User defined tags can be created in ___________ . 1
A) HTML
B) XHTML
C) XML
D) SQL
Ans C) XML
19 In which switching technique a physical path is being established for data 1
transmission over network.
A) Circuit switching
B) Packet switching
C) Message switching
D) None of the above
Ans A) Circuit Switching
19
Q20 and Q21 are Assertion(A) and Reason(R) 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) – global keyword is used to access a global variable inside a function . 1
Reasoning (R) - global keyword must be the first statement inside a function.
Ans (C) A is True but R is False
20
21 Assertion (A) – Varchar datatype is most suitable to store student names in SQL 1
table.
Reasoning (R) – Varchar has variable memory that helps in proper utilization of
memory .
Ans (A) Both A and R are true and R is the correct explanation for A
21
SECTION B – 2 MARKS
22 Which of the following statements executed by the interpreter will give an error and 2
which one will execute successfully . Give reason.
a) Remark=”V HOOD”
Remark[2]=”G”
b) Marks=[23,45,67,34,78]
Marks[2]=95
Ans a) String data type is immutable hence it gives error.
22 b) List data type is mutable hence it can be modified.

1 marks for each answer.


Award ½ marks for each partial answer
23 (a) Arrange the following operators < , or, and, ** from higher precedence to 2
lower precedence.
(b) If num=3945 , write a python statement to display the digit at hundreds
place.
Ans ** , // , <, and, or – 1 mark
23
print((num//100)%10) – 1 mark
24 Consider the list 2
gr1=[‘A’,’B’,’A’,’C’,’B’,’D’]
a) To display the position of the first occurrence of the character ‘B’ in the list
gr1.
b) To remove the fourth element from the list gr1.

OR
city=[‘mys’,’bgr’,’hub’,’has’,’bgm’]
a) To remove the last element .
b) To insert new city ‘mnd’ between ‘mys and ‘bgr’.

Ans a) gr1.index('B')
24 b) gr1.pop(3)
OR
a) city.pop(-1)
b) city.insert(1,”mnd”)

1 mark for each correct answer


25 Go through the following python program. Identify the correct output(s) from the 2
following.
import random
x=[25,55,62,22,99,74]
y=len(x)-2
for i in range(2,y):
n=random.randint(i,5)
print(x[n-1],x[n],end=" ")
i) 99 74 22 99
ii) 55 62 62 22
iii) 99 25 55 25
iv) 74 74 25 99
Ans i) 99 74 22 99
25 ii) 55 62 62 22

1 mark for each correct answer


26 The code provided below is to display even numbers using tuple. However, there are 2
syntax and logical errors in the code. Rewrite it after removing all errors. Underline
all the corrections made.
def separate_even(element):
t1=()
for a in element:
if a%2==1:
t1=t1+(a)
return t1

num=(4,5,9,6,22,3)
print(num)
print(separate_even(num)
Ans def separate_even(element):
26 t1=()
for a in element:
if a%2==0:
t1=t1+(a,)

return t1

num=(4,5,9,6,22,3)
print(num)
print(separate_even(num))

½ marks for each error


27 a) Write SQL command to add a column percentage with float data type in the 2
existing table student .
OR
Write SQL command to remove a column emailid from the existing table
student .
b) Which constraint is to be enforced on a column so that it uniquely identifies
each row of a relation?
OR
Which command is to be used to change from one database to another?

Ans a) Alter table student Add percentage float;


27 OR
Alter table student Drop email;

b) Primary key
OR
USE
1 mark for each correct answer
28 What is protocol ? Which protocol enables voice communication over internet ? 2
OR
State one advantage and one disadvantage of star topology.
Ans Protocols are a set of rules that are responsible for the communication of data
28 between various devices in the network.
VOIP – Voice over internet Protocol
(1 mark for each correct answer )
OR

Star topology – Advantage: Network remains operational even if one or two nodes
stops working or any other.
Disadvantage: Central node dependency or any other disadvantage.
(1 mark each for advantage and disadvantage )

SECTION C – 3 MARKS
29 Write a Python function SHOW_ID() which displays only the valid ID from the file 3
registration.txt . Valid ID contains 10 characters and starts with capital letter. The
registration.txt file contains registration numbers with one registration number per
line.
OR
Write a Python function to display the words from the file explore.txt whose length
is odd and starts with a vowel.

Ans def SHOW_ID():


29 file1=open("registration.txt")
content=file1.read().split()
for regno in content:
if len(regno)==10 and regno[0].isupper():
print(regno)

(½ mark for correct function header)


(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for splitting the text into words)
(1 mark for if condition and displaying)

OR

def display_words():
file1=open("explore.txt","r")
words=file1.read().split()
for oneword in words:
if len(oneword)%2==1 and oneword[0].upper() in "AEIOU":
print(oneword)
file1.close()

(½ mark for correct function header)


(½ mark for correctly opening the file)
(½ mark for correctly reading from the file)
(½ mark for splitting the text into words)
(1 mark for if condition and displaying)

30 Consider the stack INV_STACK that contains the inventory details stored as nested- 3
list. Each inventory record is represented as [item_name, cost, year] . Write the
following user-defined functions in Python to perform the
specified operations on the stack INV_STACK:

(I) push_ITEM(INV_STACK, ITEM): This function pushes the records into the
stack INV_STACK if the cost for each record is greater than Rs. 20000.
(II) pop_ITEM(INV_STACK): This function pops the topmost record from the
stack and returns it. If the stack is already empty, the function should display
"Underflow".
(III) peep(INV_STACK): This function displays the topmost element of the stack
without deleting it. If the stack is empty, the function should display 'None'.

OR

Write the definition of a user-defined function


i) push_product(product) - Which accepts product name as a parameter and
pushes in the stack ITEM, only those products which begins with ‘a’.
ii) pop_even() - To pop the topmost product name from the stack ITEM and returns
it. If the stack is already empty, the function should display "UNDERFLOW".
III) Display() - To display all element of the stack without deleting them. If the stack
is empty, the function should display 'NO ITEMS IN THE STACK - ITEM'.
Ans def push_ITEM(INV_STACK, ITEM):
31 for data in ITEM:
if data[1]>20000:
INV_STACK.append(data)

def pop_ITEM(INV_STACK):
if len(INV_STACK) < 0:
print("Underflow")
else:
print(INV_STACK.pop())
def peep(INV_STACK):
if len(INV_STACK) < 0:
print("None")
else:
print(INV_STACK[-1])

(3x1 mark for correct function body; No marks for any function header as it was a
part of the question)

OR

ITEM=[]
def push_product(product):
if product.startswith('a'):
ITEM.append(product)

def pop_even():
if len(ITEM)==0:
print("UNDERFLOW")
else:
return(ITEM.pop())

def Display():
if len(ITEM)==0:
print("NO ITEMS IN THE STACK - ITEM")
else:
print(ITEM)

(3x1 mark for correct function body; No marks for any function header as it was a
part of the question)

31 Predict the output of the following code. 3

marks=[34,23,67,12,99,85]
for i in range(2,6):
for j in range(i,len(marks)):
if i+j > 6:
print(marks[j]+i)

OR

def modify(M,times):
for i in range(times):
if M[i]%3 == 0:
M[i]%=4
if M[i]%2 == 0:
M[i]*=2
arr = [45,65,23,91,42,60,25]
modify(arr,5)
for i in arr:
print(i,end="#")

87
102
88
103
89
90
½ marks for each correct output

Or

1#65#23#91#4#60#25#
½ marks for each number along with hash

SECTION D – 4 MARKS
32 Consider the table DOCTOR as given below 4
DOCTOR
Doc_id Doc_name Salary Deptno Age Place
3423 Anirudh 30000 10 42 Mysuru
1662 Deepak 45000 20 35 Bidar
8765 Ramu 60000 10 40 Hubli
4433 Abhilasha 90000 10 28 Mysuru
Note: The table contains many more records than shown here.
A) Write the following queries:
i. To display doc_id and doc_name in descending order of age.
ii. To display total salary whose deptno is 10.
iii. To display various place without repeating.
iv. To remove the doctor record whose doc_id is 1662.
OR
B) Write the ouput with respect to the table DOCTOR
i. Select count(*) from doctor where age>35;
ii. Select doc_name , place from doctor where place like “%i%”;
iii. Select deptno, sum(salary) from doctor group by deptno;
iv. Select place, doc_id from doctor where salary between 45000 and 65000;

Ans A)
32 i) Select doc_id, doc_name from DOCTOR
order by age desc;
ii) Select sum(salary) from DOCTOR
where deptno=10;
iii) Select distinct(place)
from DOCTOR
iv) delete from DOCTOR
where doc_id = 1662;

(4 x 1 mark for each correct query)

B)
i)
i. Select count(*) from doctor where age>35;
Doc_id Doc_name
3423 Anirudh
8765 Ramu

ii. Select doc_name , place from doctor where place like “%i%”
Doc_name Place
Deepak Bidar
Ramu Hubli

iii. Select deptno, sum(salary) from doctor group by deptno.

Deptno Sum(salary)
10 180000
20 45000

iv. Select place, doc_id from doctor where salary between 45000 and 65000.

Place Doc_id
Bidar 1662
Hubli 8765

(4 x 1 mark for each correct output)

33 A csv file "olympiad.csv" contains the data of a survey of participation. Each record 4
of the
file contains the following data:
• School id
• Name of school
• Total number of students in the school
• Number of students participated.
For example, a sample record of the file may be:
[1544, ‘BHGS’,3500,450]
Write the following Python functions to perform the specified operations on this
file:
(I) A function display() to display school name and number of students not
participated.
(II) A function countmore100() to count number of schools where participation is
more than 100.

Ans I)
33 def display():
file1=open("olympiad.csv")
cr=csv.reader(file1)
for rec in cr:
notParticipated=int(rec[2])-int(rec[3])
print(rec[1],notParticipated)
file1.close()

(½ mark for opening in the file in right mode)


(½ mark for correctly creating the reader object)
(½ mark for correctly checking the condition)
(½ mark for correctly displaying the records)

II)
def countmore100():
file1=open("olympiad.csv")
cr=csv.reader(file1)
count=0
for rec in cr:
if int(rec[3])>100:
count+=1
print("Participation more than 100 ",count)
file1.close()

(½ mark for opening in the file in right mode)


(½ mark for correctly creating the reader object)
(½ mark for correct use of counter)
(½ mark for correctly displaying the counter)
34 Mr. kumar is assigned to maintain the database of STS Co. He needs to access some 4
information from the table PRODUCT and SUPPLIER. Help him to write the
queries.

PRODUCT
PID PNAME QTY PRICE SUPPCODE
23 Pendrive 100 450 SA05
45 DVD 3000 20 PS01
67 Laptop 30 24000 SA05
47 RAM 75 2500 CA11

SUPPLIER
SUPPCODE SUPPNAME RATING
SA05 INC INDIA 10
PS01 TECHNO 6
CA11 DIAMOND 8

i) To display pid, suppcode , suppname where quantity is less than 100.


ii) To display details from the supplier table where rating is more than 7.
iii) To display pname and price where suppname is ‘TECHNO’
iv) To increase the price of laptop by 25%.
OR
To display maximum price of each suppcode in product table.
Ans i. Select pid, p.suppcode , suppname from product p, supplier s
34 Where Qty <100 and p.suppcode=s.suppcode;
ii. Select * from supplier Where rating > 7;
iii. Select pname, suppname from product p, supplier s
Where suppname=’TECHNO’ and p.suppcode=s.suppcode;
iv. Update product
Set price = price * 1.25 where pname=”laptop”;
Or
Select suppcode,max(price) from product
Group by suppcode.

(4x1 mark for each correct query)

Marks to be awarded for any other correct answer .


35 Consider the table LIBRARY stored in the database BOOKS. 4

Attribute Data type


Bookno Integer
Bookname Varchar(15)
Cost Float
Year integer

Write the following Python function to perform the specified operation:


UPDATE_DISPLAY(): A function to read the book number and increase the cost of
the book by Rs. 50 if the book is published after the 2021 and display all the
record .
Assume the following for Python-Database connectivity:
Host: localhost, User: root, Password: KVBGR
Ans import mysql.connector as cs
35 con=cs.connect(host="localhost",user="root",passwd="KVBGR",database="books")

cur=con.cursor()
book_no=int(input("Book number :"))

sql1="Update library set cost= cost + 50 where bookno={}".format(book_no)


cur.execute(sql1)
con.commit()

sql1="select * from library"


cur.execute(sql1)
records=cur.fetchall()
for rec in records:
print(rec[0],rec[1],rec[2],rec[3],rec[4])
con.close()

(½ mark for correctly importing the connector object)


(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(½ mark for correct creation of first query)
(½ mark for correctly executing the first query with commit)
(½ mark for correctly executing the second query)
(½ mark for correctly displaying the data)

SECTION E – 5 MARKS
36 Mr. Keshav is organising national sports event and managing the data of various 5
school participated. For this he wants to store the following data of each school.
School id – integer
School name – string
Number of gold – integer
Number of silver – integer
Number of Bronze – integer
You have been assigned to complete the job with respect to the binary file sports.bin
where data is saved as lists.
i) Write a function to add details of new school along with medals won in
the file sports.bin.
ii) Write a function to display name of the school where number of golds in
more than 25.
iii) Write a function to display name of school and total medals won (
gold,silver,bronze) of all the schools.
Ans import pickle
36
def addrec():
file1=open("sports.bin","ab")
sid=int(input("School id "))
sname=input("School name ")
gold=int(input("Gold : "))
silver=int(input("Silver : "))
bronze=int(input("Bronze "))

rec=[sid,sname,gold,silver,bronze]
pickle.dump(rec,file1)
file1.close()

def gold25():
file1=open("sports.bin","rb")
print("Schools got gold more than 25")
try:
while True:
rec=pickle.load(file1)
if rec[2]>25:
print(rec[1])
except EOFError:
file1.close()

def school_total_medal():
file1=open("sports.bin","rb")
print("Schools and medals ")
try:
while True:
rec=pickle.load(file1)
total=rec[2]+rec[3]+rec[4]
print(rec[1],total,sep=' - ')
except EOFError:
file1.close()

(1/2 mark of import pickle)


(1/2 mark for input)
(1/2 mark for opening file in append mode and 1/2 mark for using dump)
(1/2 mark for opening file in read mode and 1/2 mark for using load)
(1 mark for checking the condition and displaying the value) – function 2
(1 mark for checking the condition and displaying data correctly)

37 HI TECH Company is setting up a secured network for its campus at Bengaluru for 5
operating their day-to-day office & web based activities. They are planning to have
network connectivity between four buildings. Answer the question (i) to (v) after
going through the building positions in the campus & other details which are given
below:

Block to Block distance in meters

From To Distance
Admin Main 140
Admin Finance 85
Admin Academic 150
Finance Main 120
Finance Academic 45
Main Academic 70

Number of computer in each block

BLOCK NUMBER OF
COMPUTER
Admin 50
Finance 20
Main 30
Academic 85
i. Suggest the most suitable block to house the server of the network with
reason.
ii. Draw a layout to efficiently connect all the blocks.
iii. Which device to be used to connect computers in each block.
iv. Suggest placement of repeater if needed as per layout with reason.
v. Hi Tech company Bengaluru is planning to connect to its other office at
Dharwad , which is more than 400 KM. Which type of network will be
formed. Justify your answer.
Ans i) Academic
37

ii)

iii) Switch / Hub


iv) Repeater to be placed between Admin to Academic as the distance is
more than 100 mtrs .
v) WAN – Computer connected over large distances.

(1 mark for each correct answer)

*****

You might also like