100% found this document useful (2 votes)
4K views17 pages

Computer Science (083) Class 12

1. The document discusses a pre-board exam for Class XII Computer Science students in Kendriya Vidyalaya Sangathan, Bengaluru Region. It provides a sample paper with 70 maximum marks and 3 hours duration. 2. The sample paper contains a marking scheme with 25 multiple choice questions in Section A worth 1 mark each, and 5 other questions in Section B worth up to 2 marks each. 3. The questions test concepts in Python, databases, networking and other computer science topics. The marking scheme provides the answers and explanations for full marks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
4K views17 pages

Computer Science (083) Class 12

1. The document discusses a pre-board exam for Class XII Computer Science students in Kendriya Vidyalaya Sangathan, Bengaluru Region. It provides a sample paper with 70 maximum marks and 3 hours duration. 2. The sample paper contains a marking scheme with 25 multiple choice questions in Section A worth 1 mark each, and 5 other questions in Section B worth up to 2 marks each. 3. The questions test concepts in Python, databases, networking and other computer science topics. The marking scheme provides the answers and explanations for full marks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

KENDRIYA VIDYALAYA SANGATHAN

BENGALURU REGION
FIRST PRE-BOARD EXAM (SESSION 2022-23)

CLASS: XII Sample Paper 2 MAX MARKS:70


SUBJECT: COMPUTER SCIENCE TIME: 3 HOURS
MARKING SCHEME
SECTION A
1. State True or False 1
“Python has a set of keywords that can also be used to declare variables”
A False
2. Which of the following is not a valid python operator? 1
a) % b) in c) # d) **
A #
3. What will be the output of the following python dictionary operation? 1
data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)
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.
A {'A':4000, 'B':2500, 'C':3000}
4. 1
print(True or not True and False)
Choose one option from the following that will be the correct output after
executing the above python expression.
a) False b) True c) or d) not
A True
5. Select the correct output of the following python code: 1
str="My program is program for you"
t = str.partition("program")
print(t)
a) ('My ', 'program', ' is ', 'program', ' for you')
b) ('My ', 'program', ' is program for you')
c) ('My ', ' is program for you')
d) ('My ', ' is ', ' for you')
A a) ('My ', 'program', ' is program for you')

1|Page
6. Which of the file opening mode will open the file for reading and writing in 1
binary mode.
a) rb b) rb+ c) wb d) a+
A rb+
7. Which of the following statements is True? 1
a) There can be only one Foreign Key in a table.
b) There can be only one Unique key is a table
c) There can be only one Primary Key in a Table
d) A table must have a Primary Key.
A There can be only one Primary Key in a Table
8. Which of the following is not part of a DDL query? 1
a) DROP
b) MODIFY
c) DISTINCT
d) ADD
A DISTINCT
9. Which of the following operations on a string will generate an error? 1
a) "PYTHON"*2
b) "PYTHON" + "10"
c) "PYTHON" + 10
d) "PYTHON" + "PYTHON"
A "PYTHON" + 10
10. _______________ Keyword is used to obtain unique values in a SELECT 1
query
a) UNIQUE
b) DISTINCT
c) SET
d) HAVING
A DISTINCT
11. Which of the following python statement will bring the read pointer to 10th 1
character from the end of a file containing 100 characters, opened for
reading in binary mode.
a) File.seek(10,0)
b) File.seek(-10,2)
c) File.seek(-10,1)
d) File.seek(10,2)
A File.seek(-10,2)

2|Page
12. Which statement in MySql will display all the tables in a database? 1
a) SELECT * FROM TABLES;
b) USE TABLES;
c) DESCRIBE TABLES;
d) SHOW TABLES;
A SHOW TABLES;
13. Which of the following is used to receive emails over Internet? 1
a) SMTP b) POP3 c) PPP d) VoIP
A POP3
14 What will be the output of the following python expression? 1
print(2**3**2)
a) 64 b) 256 c) 512 d) 32
A 512
15. Which of the following is a valid sql statement? 1
a) ALTER TABLE student SET rollno INT(5);
b) UPDATE TABLE student MODIFY age = age + 10;
c) DROP FROM TABLE student;
d) DELETE FROM student;
A DELETE FROM student;
16. Which of the following is not valid cursor function while performing database 1
operations using python. Here Mycur is the cursor object?
a) Mycur.fetch()
b) Mycur.fetchone()
c) Mycur.fetchmany(n)
d) Mycur.fetchall()
A Mycur.fetch()
Q17 and 18 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
17. Assertion (A): A variable declared as global inside a function is visible with 1
changes made to it outside the function.
Reasoning (A): All variables declared outside are not visible inside a function
till they are redeclared with global keyword.
A Both A and R are true and R is the correct explanation for A

3|Page
18. Assertion (A): A binary file in python is used to store collection objects like 1
lists and dictionaries that can be later retrieved in their original form using
pickle module.
Reasoning (A): A binary files are just like normal text files and can be read
using a text editor like notepad.
A A is True and R is False
SECTION B
19. Sameer has written a python function to compute the reverse of a number. 2
He has however committed a few errors in his code. Rewrite the code after
removing errors also underline the corrections made.
define reverse(num):
rev = 0
While num > 0:
rem == num %10
rev = rev*10 + rem
num = num//10
return rev
print(reverse(1234))
A def reverse(num):
rev = 0
while num > 0:
rem = num %10
rev = rev*10 + rem
num = num//10
return rev
print(reverse(1234))
20. Mention two differences between a Hub and a switch in networking. 2
OR
Mention one advantage and one disadvantage of Star Topology.

A Hub Switch
Hub is a passive Device Switch is an active device
Hub broadcasts messages to all Switch sends the messages to
nodes intended node.
Or any other valid difference between the two. Each difference carries 1
mark.
OR

Advantage: The network remains operational even if one of the nodes stops
working.
Disadvantage: The network stops working if the central hub stops working.
Or any other valid advantage or disadvantage. Each carries 1 mark
4|Page
21. a) What will be the output of the following string operation. 1
str="PYTHON@LANGUAGE"
print(str[2:12:2])

b) Write the output of the following code. 1


data = [1,2,4,5]
for x in data:
x = x + 10
print(data)
A TO@AG - No partial marking
[1,2,4,5] - No partial marking
22 Mention two differences between a PRIMARY KEY and a UNIQUE KEY 2
A PRIMARY KEY UNIQUE KEY
There can be only one primary key in a There can be more than one unique keys
table in a table
The primary key cannot have null values Unique can have null values
Each difference carries 1 mark.
23. a) Expand the following abbreviations: 1
i) URL ii) TCP

b) What is the use of VoIP? 1


A i) Uniform Resource Locator - 1/2
ii) Transmission Control Protocol - ½

VoIP is used to transfer audio and video over internet - 1


24. Predict the output of the following python code: 2
def foo(s1,s2):
l1=[]
l2=[]
for x in s1:
l1.append(x)
for x in s2:
l2.append(x)
return l1,l2
a,b=foo("FUN",'DAY')
print(a,b)

OR
Predict the output of the following python code:
data = [2,4,2,1,2,1,3,3,4,4]
d = {}
for x in data:
5|Page
if x in d:
d[x]=d[x]+1
else:
d[x]=1
print(d)
A ['F', 'U', 'N'] ['D', 'A', 'Y'] Each list correctly written will fetch 1 mark. ½ mark
can be given if the list is figured out in the answer.
OR
{2: 3, 4: 3, 1: 2, 3: 2}
The dictionary elements can be written in any order.
25. A MySQL table, sales have 10 rows. The following queries were executed on 2
the sales table.
SELECT COUNT(*) FROM sales;
COUNT(*)
10

SELECT COUNT(discount) FROM sales;


COUNT(discount)
6
Write a statement to explain as to why there is a difference in both the
counts.
OR
What is the difference between a Candidate Key and an Alternate Key
A The values are different because discount column is having 4 rows with NULL
values.

OR

CANDIDATE KEY ALTERNATE KEY


All the attributes in a relation that All the leftover candidate keys after
have the potential to become a selecting the primary key
Primary key
SECTION C
26. a) Consider the following tables Emp and Dept: 1+2

6|Page
Relation: Emp
Relation: Dept
empcode ename deptid Salary
deptid dname
1001 TOM 10 10000
10 Physics
1002 BOB 11 8000
11 Chemistry
1003 SID 10 9000

1004 JAY 12 9000 12 Biology

What will be the output of the


following statement?
SELECT * FROM Emp NATURAL JOIN Dept WHERE dname='Physics';

b) Write output of the queries (i) to (iv) based on the table Sportsclub
Table Name: Sportsclub
playerid pname sports country rating salary

10001 PELE SOCCER BRAZIL A 50000

10002 FEDERER TENNIS SWEDEN A 20000

10003 VIRAT CRICKET INDIA A 15000

10004 SANIA TENNIS INDIA B 5000

10005 NEERAJ ATHLETICS INDIA A 12000

10006 BOLT ATHLETICS JAMAICA A 8000

10007 PAUL SNOOKER USA B 10000


(i) SELECT DISTINCT sports FROM Sportsclub;
(ii) SELECT sports, MAX(salary) FROM Sportsclub GROUP BY sports
HAVING sports<>'SNOOKER';
(iii) SELECT pname, sports, salary FROM Sportsclub WHERE
country='INDIA' ORDER BY salary DESC;
(iv) SELECT SUM(salary) FROM Sportsclub WHERE rating='B';
A a)
deptid empcode ename Salary dname
10 1001 TOM 10000 Physics
10 1003 SID 9000 Physics

7|Page
i) DISTINCT sports
SOCCER
TENNIS
CRICKET
ATHLETICS
SNOOKER
ii)

Sports MAX(salary)
SOCCER 50000
TENNIS 20000
CRICKET 15000
ATHLETICS 12000
iii)
pname sports salary
VIRAT CRICKET 15000
NEERAJ ATHLETICS 12000
SANIA TENNIS 5000
iv)
SUM(salary)
15000
27. A pre-existing text file data.txt has some words written in it. Write a python 3
function displaywords() that will print all the words that are having length
greater than 3.
Example:
For the fie content:
A man always wants to strive higher in his life
He wants to be perfect.

The output after executing displayword() will be:


Always wants strive higher life wants perfect

OR

A pre-existing text file info.txt has some text written in it. Write a python
function countvowel() that reads the contents of the file and counts the
occurrence of vowels(A,E,I,O,U) in the file.

8|Page
A def displaywords():
f = open('data.txt','r')
s = f.read()
lst = s.split()
for x in lst:
if len(x)>3:
print(x, end=" ")
f.close()

OR

def countvowels():
f - open('info.txt', 'r')
s = f.read()
count = 0
for x in s:
if x in 'AEIOU':
count+=1
print(count)
f.close()

Correct definition of function will fetch 3 marks. For each syntax error ½
mark may be deducted. No marks to be deducted for using a different logic.
28. Based on the given set of tables write answers to the following questions. 3
Table: flights
flightid model company
10 747 Boeing
12 320 Airbus
15 767 Boeing
Table: Booking
ticketno passenger source destination quantity price Flightid
10001 ARUN BAN DEL 2 7000 10
10002 ORAM BAN KOL 3 7500 12
10003 SUMITA DEL MUM 1 6000 15
10004 ALI MUM KOL 2 5600 12
10005 GAGAN MUM DEL 4 5000 10
a) Write a query to display the passenger, source, model and price for all
bookings whose destination is KOL.
b) Identify the column acting as foreign key and the table name where it
is present in the given example.

9|Page
A a) SELECT passenger, source, model, price FROM booking, flights WHERE
bookings.flightid = flights.flightid AND destination='KOL';

2 marks for correct answer. ½ mark to be deducted for each error.

b) Flighted in the bookings table is the foreign key. (1 mark)


29. Write a function modilst(L) that accepts a list of numbers as argument and 3
increases the value of the elements by 10 if the elements are divisible by 5.
Also write a proper call statement for the function.
For example:
If list L contains [3,5,10,12,15]
Then the modilist() should make the list L as [3,15,20,12,25]
A def modilst(L):
for i in range(len(L)):
if L[i] % 5 == 0:
L[i]+=10

L = [12,10,15,20,25]
modilst(L)
print(L)

½ mark to deducted for each syntax error. Marks to be awarded for a


different logic. 1 mark to be deducted if the function call is not written
30. A dictionary contains the names of some cities and their population in crore. 3
Write a python function push(stack, data), that accepts an empty list, which
is the stack and data, which is the dictionary and pushes the names of those
countries onto the stack whose population is greater than 25 crores.
For example :
The data is having the contents {'India':140, 'USA':50, 'Russia':25, 'Japan':10}
then the execution of the function push() should push India and USA on the
stack.

OR

A list of numbers is used to populate the contents of a stack using a function


push(stack, data) where stack is an empty list and data is the list of numbers.
The function should push all the numbers that are even to the stack. Also
write the function pop(stack) that removes the top element of the stack on
its each call. Also write the function calls.

10 | P a g e
A data={'India':140, 'USA':50, 'Russia':25, 'Japan':10}
stack=[]
def push(stack, data):
for x in data:
if data[x]>25:
stack.append(x)
push(stack, data)
print(stack)

½ mark should be deducted for all incorrect syntax. Full marks to be


awarded for any other logic that produces the correct result.

OR

data = [1,2,3,4,5,6,7,8]
stack = []
def push(stack, data):
for x in data:
if x % 2 == 0:
stack.append(x)
def pop(stack):
if len(stack)==0:
return "stack empty"
else:
return stack.pop()

push(stack, data)
print(pop(stack))

½ mark should be deducted for all incorrect syntax. Full marks to be


awarded for any other logic that produces the correct result.

SECTION D
31 Magnolia Infotech wants to set up their computer network in the Bangalore 5
. based campus having four buildings. Each block has a number of computers
that are required to be connected for ease of communication, resource
sharing and data security. You are required to suggest the best answers to
the questions i) to v) keeping in mind the building layout on the campus.

11 | P a g e
HR
Development

Admin
Logistics

Number of Computers.
Block Number of computers
Development 100
HR 120
Admin 200
Logistics 110

Distance Between the various blocks


Block Distance
Development to HR 50m
Development to Admin 75m
Development to Logistics 120m
HR to Admin 110m
HR to Logistics 50m
Admin to Logistics 140m

i) Suggest the most appropriate block to host the Server. Also justify
your choice.
ii) Suggest the device that should should be placed in the Server
building so that they can connect to Internet Service Provider to
avail Internet Services.
iii) Suggest the wired medium and draw the cable block to block layout
to economically connect the various blocks.
iv) Suggest the placement of Switches and Repeaters in the network
with justification.
v) Suggest the high-speed wired communication medium between
Bangalore Campus and Mysore campus to establish a data network.
A i) Admin Block since it has maximum number of computers.
ii) Modem should be placed in the Server building
iii) The wired medium is UTP/STP cables.

Development HR

Admin
Logistics

12 | P a g e
iv) Switches in all the blocks since the computers need to be
connected to the network. Repeaters between Admin and HR block
& Admin and Logistics block. The reason being the distance is more
than 100m.
v) Optical Fiber cable connection.

32 a) Write the output of the following code: 2+3


.
def change(m, n=10):
global x
x+=m
n+=x
m=n+x
print(m,n,x)
x=20
change(10)
change(20)

OR (only in a part)

What will be the output of the following python program?


str = ""
name = "9@Days"
for x in name:
if x in "aeiou":
str+=x.upper()
elif not x.isalnum():
str+="**"
elif x.isdigit():
pass
else:
str+=x.lower()
print(str)
b) Sumitra wants to write a program to connect to MySQL database using
python and increase the age of all the students who are studying in class 11
by 2 years.
Since she had little understanding of the coding, she left a few blank spaces
in her code. Now help her to complete the code by suggesting correct coding
for statements 1, 2 and 3.

13 | P a g e
import ________________ as myc # Statement 1
con = myc.connect(host="locahost", user="root", passwd="",
database="mydb")
mycursor = __________________ #Statement 2
sql = "UPDATE student SET age=age+2 WHERE class='XI'"
mycursor.execute(sql)
sql = "SELECT * FROM student"
mycursor=con.execute(sql)
result = _____________________ #Statement 3
for row in result:
print(row)

Statement 1 : The required module to be imported


Statement 2: To initialize the cursor object.
Statement 3: To read all the rows from the cursor object

A a) 70 40 30
110 60 50
1 mark for each correct row of answer. Partial marks to be given if
partial correct answers are there.

OR

**dAys
2 marks for correct answer. Partial marks may be given for partially
correct answer.
b) mysql.connector
c) con.cursor()
d) mycursor.fetchall()

1 mark for each correct answer


33 A binary file data.dat needs to be created with following data written it in the 2+3
. form of Dictionaries.
Rollno Name Age
1001 TOM 17
1002 BOB 16
1003 KAY 16
Write the following functions in python accommodate the data and
manipulate it.
a) A function insert() that creates the data.dat file in your system and
writes the three dictionaries.

14 | P a g e
b) A function read() that reads the data from the binary file and displays
the dictionaries whose age is 16.

A import pickle
def insert():
d1 = {'Rollno':1001, 'Name':'TOM', 'Age':17}
d2 = {'Rollno':1002, 'Name':'BOB', 'Age':16}
d3 = {'Rollno':1003, 'Name':'KAY', 'Age':16}
f = open("data.dat","wb")
pickle.dump(d1,f)
pickle.dump(d2,f)
pickle.dump(d3,f)
f.close()

def read():
f = open("data.dat", "rb")
while True:
try:
d = pickle.load(f)
if d['Age']==16:
print(d)
except EOFError:
break
f.close()

The insert() function has 2 marks. Deduct ½ mark for each syntax error
The read() function carries 3 marks. Deduct ½ marks for each syntax error
34 Tarun created the following table in MySQL to maintain stock for the items 1+1+
. he has. 2

Table : Inventory
Productid pname company stock price rating

10001 Biscuit Parley 1000 15 C

10002 Toffee Parley 500 5 B

10003 Eclairs Cadbury 800 10 A

10004 Cold Drink Coca Cola 500 25 NULL

10005 Biscuit Britania 500 30 NULL

10006 Chocolate Cadbury 700 50 C


Based on the above table answer the following questions.

15 | P a g e
a) Identify the primary key in the table with valid justification.
b) What is the degree and cardinality of the given table.
c) Write a query to increase the stock for all products by 20 whose
company is Parley.
OR (only for part c)
Write a query to delete all the rows from the table which are not
having any rating.
A a) The Primary Key should be Productid since it uniquely identifies each
row. (1)
b) Degree – 6 Cardinality – 6 (½ + ½)
c) UPDATE inventory SET stock=stock+10 WHERE company = 'Parley';
OR
DELETE FROM inventory WHERE RATING IS NULL; (2)
35 Sudheer has written a program to read and write using a csv file. He has
. written the following code but failed to write completely, leaving some
blanks. Help him to complete the program by writing the missing lines by
following the questions a) to d)

_________________ #Statement 1
headings = ['Country','Capital','Population']
data = [['India', 'Delhi',130],['USA','Washington DC',50],[Japan,Tokyo,2]]
f = open('country.csv','w', newline="")
csvwriter = csv.writer(f)
csvwriter.writerow(headings)
________________ #Statement 2
f.close()
f = open('country.csv','r')
csvreader = csv.reader(f)
head = _________________ #Statement 3
print(head)
for x in __________: #Statement 4
if int(x[2])>50:
print(x)

a) Statement 1 – Write the python statement that will allow Sudheer


work with csv files.
b) Statement 2 – Write a python statement that will write the list
containing the data available as a nested list in the csv file
c) Statement 3 – Write a python statement to read the header row in to
the head object.
d) Statement 4 – Write the object that contains the data that has been
read from the file.

16 | P a g e
A a) import csv
b) csvwriter.writerows(data)
c) next(csvreader)
d) csvreader
1 mark for each correct answer.

****End****

17 | P a g e

You might also like