0% found this document useful (0 votes)
383 views

NVS Preboard Marking Scheme - CS - 12

The document provides a computer science preboard exam answer key for Class XII Session 2022-23. It contains 26 multiple choice and written response questions across three sections: Section A contains 15 multiple choice questions testing concepts like Python operators, lists, tuples, file handling, SQL, and databases. Section B has 5 written response questions involving Python code corrections, describing differences, and writing outputs. Section C has 6 questions involving a SQL join and written responses.
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
0% found this document useful (0 votes)
383 views

NVS Preboard Marking Scheme - CS - 12

The document provides a computer science preboard exam answer key for Class XII Session 2022-23. It contains 26 multiple choice and written response questions across three sections: Section A contains 15 multiple choice questions testing concepts like Python operators, lists, tuples, file handling, SQL, and databases. Section B has 5 written response questions involving Python code corrections, describing differences, and writing outputs. Section C has 6 questions involving a SQL join and written responses.
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/ 18

Class: XII Session: 2022-23

Computer Science (083)


Preboard 1 Answerkey

SECTION A
1 Which of the following is valid arithmetic operator in Python: 1M
(i) // (ii) ? (iii) < (iv) and
Ans: (i)
2 Sushma gets the current date and time as a string x. Its value is 1M
"2021-10-30 12:49:44.216062".
Sushma prints the value of x[11:16] and gets "12:49". Which of these will
contain the date in yyyy-mm-dd format?
a. x[0:9]
b. x[0:10]
c. x[1:10]
d. x[1:11]
Ans: b
3 Which of these Python data structures cannot have duplicate items and does not 1M
support ordering?
a. list
b. tuple
c. dictionary
d. set
Ans: c
4 Consider a list a=[34,35,26,78,90,[12,13,14],[5,6,7],29,45] 1M
What is the output of a[-4][-2]?
a.90
b.5
c.13
d.12
Ans: c
5 Consider a list b=[90,85,89,78,3,5] 1M
b.insert(-1,7)
print(b)
a. [90,85,89,78,3,5,7]
b. [90,85,89,78,3,7,5]
c. [90,7,85,89,78,3,5]
d. [7,90,85,89,78,3,5]
Ans: b
6 Which output lines of the following program will print the same results? 1M
tup1 = (10, 20, 30, 40, 50, 60, 70, 80, 90)
print(tup1[5:-1]) # 1
print(tup1[5]) # 2
print(tup1[5:]) # 3
print(tup1[-4:8]) # 4
a. (1) and (2)
b. (1) and (4)
c. (2) and (3)
d. (1), (3) and (4)
Ans: b
7 Ms. Hetvee is working on a string program. She wants to display last four 1M
characters of a string object named s. Which of the following is statement is true?
a. s[4:]
b. s[:4]
c. s[-4:]
d. s[:-4]
Ans: c
8 Which of the following mode in file opening statement results or 1M
generates an error if the file does not exist?
(a) a+ (b) r+ (c) w+ (d) None of the above
Ans: b
9 A file customer.txt has been created. Now Which of the following function(s) can 1 M
be used to open the file in only reading mode?

a) i and iii only


b) i, ii and iii
c) ii and iii
d) iv only
Ans: a
10 Table Employee has 4 records and 3 attributes and Table Dept has 3 records and 1M
4 attributes in it. Mr. Jain wants to display all information stored in both of these
related tables. He forgot to specify equi-join condition in the query. What will be
the degree and cardinality of the resultant table ?

a) Degree 12 and Cardinality 4


b) Degree 12 and Cardinality 3
c) Degree 12 and Cardinality 7
d) Degree 7 and Cardinality 12

Ans d
11 The RDBMS terminology for a row is 1M
(a) Tuple (b) relation (c) attribute (d) degree
Ans: a
12 1M

a) SELECT * FROM Persons WHERE

Ans: c
13 What does the ALTER TABLE clause do? 1M
a) The SQL ALTER TABLE clause modifies a table definition by altering,
adding, or deleting table columns and/or constraints
b) The SQL ALTER TABLE clause is used to insert data into database table
c) THE SQL ALTER TABLE deletes data from database table
d) The SQL ALTER TABLE clause is used to delete a database table
Ans: a
14 Which of the following command is used to change the rows that already exist in 1M
a table?
a) Insert.
b) Union.
c) Update.
d) Select
Ans: c
15 Fill in the blank: 1M
_________ is a non-key attribute, whose values are derived from the
primary key of some other table.
(a) Primary Key
(b) Foreign Key
(c) Candidate Key
(d) Alternate Key
Ans: b
16 FTP stand for_____________________ 1M
a)Foreign Transfer protocol b)Fiber Tech Protocol c)Fiber Transfer Protocol
d)File Transfer Protocol
Ans: d
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 :An existing file is opened in the write mode the previous data will 1M
be erased.

Reasoning R: When the existing file is opened in write mode the file object will
be positioned at the end of the file.
Ans: c

18 Assertion A: Stack is a linear data structure which follows a particular order 1M


in which the operations are performed. The order may be LIFO(Last In First
Out) .
Reasoning R: When we put data in a Stack, it processes the last entry first .
Ans: a
SECTION B
19 Rewrite the following code in python after removing all syntax error(s). 2M
Underline each correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K*4)
Else:
print (K+3)
Ans.
To=30
for K in range(0,To) :
if k%4==0:
print (K*4)
else:
print (K+3)
( ½ mark for each correction)
20 Write two points of difference between hub and switch. 2M
OR
Write two points of difference between star and bus topology.

ANS :

1. A hub is a networking device that connects multiple PCs to a single network,


whereas a Switch connects multiple devices on a single computer network.
2. A hub operates on the OSI physical layer, whereas a switch operates on the
OSI data link layer.
OR

S.NO
. Star Topology Bus Topology

Bus topology is a topology where


Star topology is a topology each device is connected to a single
in which all devices are cable which is known as the
1. connected to a central hub. backbone.

In star topology, if the In a Bus topology, the failure of the


central hub fails then the network cable will cause the whole
2. whole network fails. network to fail.

(1 mark for each correct point)


21 Write the output of the following: 2M
L=[ ]
L1 = [ ]
for i in range (16,10):
L.append(i)
for i in range (20,4,-2):
L1.append(i)

Ans:

L=[]
L1 = [20, 18, 16, 14, 12, 10, 8, 6]
(1 mark each for correct output)
22 Define the term cardinality and degree. 2M
Ans: Cardinality refers to the number of tuples/rows in a table whereas,
Degree refers to the number of attributes/columns in a table.
23 (a) Write the full forms of the following: 2M
(i) ARPANET (ii) SMTP
Advanced Research Projects Agency Network ( ½ mark )
SIMPLE MAIL TRANSFER PROTOCOL ( ½ mark )

b) What is NIC? Give other name of NIC.


Ans.
Stands for Network Interface Card. It is used to connect a computer to a network.
Also known as Network Adapter or Ethernet Card.

(1 mark)

24 Find the output of the following code: 2M


Name="PythoN3.1"
R=""
for x in range(len(Name)):
if Name[x].isupper():
R=R+Name[x].lower()
elif Name[x].islower():
R=R+Name[x].upper()
elif Name[x].isdigit():
R=R+Name[x-1]
else:
R=R+"#"
print(R)

Ans: pYTHOnN#@

(2 mark for correct output)

OR

Predict the output of the Python code given below:


tuple1 = (11, 22, 33, 44, 55 ,66)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)

Ans: (22,44,66)
( ½ mark for each correct digit , ½ mark for enclosing in parenthesis)

25 How is alter table statement different from UPDATE statement? 2M


Ans.:

Alter table is different than update in the following ways:


1. Alter is DDL command, Update is DML command
2. Alter is used to modify the structure of table where as update is used to modify
the table content
(1 mark for each point)
OR
Ans. :
update company set comm=500 where sales>200000;
(2 marks for correct query)
SECTION C

26 (a) Consider the following tables Foods and Company 1+2


M
Table: Foods
ITEM- ITEMNAME COMPANY_ID
ID
1 CHEK MIX 16
2 CHEESE-IT 15
6 BN-BISCUTT 15
4 POTRICE 15

Table: Company
ITEMID COMPANYNAME
15 JACK JILL
16 AKAS FOOD
17 FOODIES
19 SIP N BITE

What will be the output of the following statement?


SELECT * FROM Foods NATURAL JOIN Company;
Ans:

ITEM-ID ITEMNAME COMPANY_ID COMPANYNA


ME
1 CHEK MIX 16 AKAS FOOD
2 CHEESE-IT 15 JACK JILL
6 BN-BISCUTT 15 JACK JILL
4 POTRICE 15 JACK JILL
(1 mark for correct output)

(b) Write the output of the queries (i) to (iv) based on the table, TECH_COURSE
given below:
ENO NAME DOJ DOB GENDER DCODE

1111 MISKA 2020/03/01 1997/11/15 F 10

1112 AKSHAY 2018/06/05 1998/12/04 M 20


1113 NEEL 2021/07/01 2000/10/20 M 10

1114 ANKITA 2016/04/25 2001/10/27 F 30

1115 MOHIT 2016/12/22 2003/11/02 M 40

Table:DEPT

DCODE DEPARTMENT LOCATION


10 AGRICULTURE ANAND
20 MINES NADIAD
30 TPP KHEDA
40 MECHANICAL AHMEDABAD

1. SELECT COUNT(*),DCODE FROM EMPLOYEE GROUP BY


DCODE HAVING COUNT(*)>1;
2. SELECT DISTINCT DEPARTMENT FROM DEPT;
3. SELECT NAME,DEPARTMENT FROM EMPLOYEE E,DEPT D
WHERE E.DCODE=D.DCODE AND ENO<1113
4. SELECT MAX(DOJ), MIN(DOB) FROM EMPLOYEE;

Ans:

1. COUNT(*) DCODE

2 10

2. DISTINCT DEPARTMENT

AGRICULTURE
MINES
TPP
MECHANICAL
3. NAME DEPARTMENT
-
MISKA AGRICULTURE
AKSHAY MINES
4. MAX(DOJ) MIN(DOB)

2021/07/01 1997/11/15
(1/2 mark for each output)

27 Write a function in Python to read lines from a text file "notes.txt", to find and 3M
display the occurrence of the word "the".

For example: If the content of the file is:


"India is the fastest-growing economy. India is looking for more investments
around the globe. The whole world is looking at India as a great market. Most of
the Indians can foresee the heights that India is capable of reaching."
The output should be 5.

Source Code

def count_words():
file = open("notes.txt","r")
count = 0
data = file.read()
words = data.split()
for word in words:
if word =="the" or word =="The":
count += 1
print(count)
file.close()

count_words()
( ½ mark for correctly opening and closing the file
½ for read()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output)

OR
Write a function display_words() in python to read lines from a text file
"story.txt", and display those words, which are less than 4 characters.

Source Code

def display_words():
file = open("poem.txt","r")
data = file.read()
words = data.split()
for word in words:
if len(word) < 4:
print(word, end=" ")
file.close()
display_words()
( ½ mark for correctly opening and closing the file
½ for read()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output)
28 Consider the table given below: Table Faculty
TEACHER PHONE
NAME ADDRESS STATE
ID NUMBER

T001 Avinash Ahmedabad Gujarat 9825741256

T002 Akhilesh Jaipur Rajasthan 9824456321

T003 Shivansh Mumbai Maharashtra 9327045896

T004 Minaxi New Delhi Delhi 9012547863

TABLE: COURSE
COURSEID SUBJECT TEACHERID FEE

1001 Computer Science T001 6750

1002 Informatics Practices T004 4550

i. With reference to the above given tables, write commands in SQL for (i)
and (ii) and output for (iii) :
o (i) select courseid, teacherid, name, phonenumber from course c,
faculty f where c.teacherid=f.teacherid and address like

o (ii) select teacherid, name, subject from course c, faculty f where

o (iii) SELECT CourseId, Subject,TeacherId,Name,PhoneNumber


FROM Faculty,Course WHERE Faculty.TeacherId =
Course.TeacherId AND Fee>=5000;
o (iv) Update c

Ans:
i.
courseid Teacherid Name Phoneno
1002 T004 Minaxi 9012547863
ii. No Records
iii.
Courseid Subject Teacherid Name Phonenumber
Computer Avinash 9825741256
1001 T001
Science
iv. Query ok 2 records updated.

(1 /2 mark for each output)


i. Write the command to view all databases.
Show databases;
(1 mark for correct query)
29 def LShift(Arr,n): 3M
L=len(Arr)
for x in range(0,n):
y=Arr[0]
for i in range(0,L-1):
Arr[i]=Arr[i+1]
Arr[L-1]=y
print(Arr)
Note :

Using of any correct code giving the same result is also accepted

(1/2 mark for function header


1 mark for correct iterating statement
1 mark for swapping
½ mark for displaying list)
30 Vedika has created a dictionary containing names and marks as key-value pairs 3M
of 5 students. Write a program, with separate user-defined functions to perform
the following operations:

1. Push the keys (name of the student) of the dictionary into a stack, where
the corresponding value (marks) is greater than 70.
2. Pop and display the content of the stack.

The dictionary should be as follows:

Then the output will be: Umesh Vishal Ishika

Ans:
def push(stk,item):
stk.append(item)

def Pop(stk):
if stk==[]:
return None
else:
return stk.pop()

stk=[]
d={"Ramesh":58, "Umesh":78, "Vishal":90, "Khushi":60, "Ishika":95}
for i in d:
if d[i]>70:
push(stk,i)

while True:
if stk!=[]:
print(Pop(stk),end=" ")
else:
break

OR

Write functions AddPlayer(player) and DeletePlayer(player) in python to add and


remove a player by considering them as push and pop operations in a stack.

Ans:
def AddPlayer(player):
pn=input("enter player name:")
player.append(pn)
def DeletePlayer(player):
if player==[]:
print("No player found")
else:
return player.pop()

SECTION D
31 G.R.K International Inc. is planning to connect its Bengaluru Office Setup with 5M
its Head Office in Delhi. The Bengaluru Office G.R.K. international Inc. is
spread across and area of approx. 1 square kilometer, consisting of 3 blocks
Human Resources, Academics and Administration.
You as a network expert have to suggest answers to the four queries (i) to (iv)
raised by them.

Notes : Keep the distance between blocks and number of computers in each block
in mind, while providing them the solutions.
1. Suggest the most suitable block in the Bengaluru Office Setup, to
host the server.
Give a suitable reason with your suggestion.
2. Suggest the cable layout among the various blocks within the
Bengaluru Office Setup for connecting the Blocks.
3. Suggest a suitable networking device to be installed in each of the
blocks essentially required for connecting computers inside the
blocks with fast and efficient connectivity.
4. Suggest the most suitable media to provide secure, fast and reliable
data connectivity between Delhi Head Office and the Bengaluru
Office Setup. 1M
5. Suggest a device/software to be installed in the Begaluru Campus
to take care of data security.

Ans:

1. Human Resources because it has maximum number of computers.


2. 1M

1M
1M
1M

3. Switch /Hub
4. Satellite link
5. Firewall

32 What are the possible outcome(s) executed from the following code? Also, 5
specify the maximum and import random.

PICK=random.randint (0,3)
CITY= ["DELHI", "MUMBAI", "CHENNAI", "KOLKATA"];
for I in CITY :
for J in range (1, PICK)
print (I, end = " ")
print ()
(i) (ii)
DELHIDELHI DELHI
MUMBAIMUMBAI DELHIMUMBAI
CHENNAICHENNAI DELHIMUMBAICEHNNAI
KOLKATAKOLKATA
(iii) (iv)
DELHI DELHI
MUMBAI MUMBAIMUMBAI
CHENNAI KOLKATAKOLKATAKOLKATA
KOLKATA

Ans: Option (i) and (iii) are possible

PICKER maxval = 3 minval = 0

b. A resultset is extracted from the Customer table using the cursor object (that
has been already created) by giving the following statement.
Rec_Data=cursor.fetchall()
(a) How many records of the table will be returned by fetchall() method? 1M
(b) What will be the datatype of Rec_Data object after the given command is
executed?

Ans. (a) In case the table has records then all the records will be returned as a list 1M
of tuples, otherwise it will return an empty list.
(b) List of tuples

OR

a. Find and write the output of the following python code:


a=10
def call():
global a 2M
a=15
b=20
print(a) 1M
call()

Ans: 15

Consider the table : IPL2022 in which Tina wants to fetch rows. For this she
wrote a program in which some code is missing. Help her to complete the
following code.
import ______________ as ms #line1
cn=ms.connect(host='localhost',user='root',passwd='root',database='IPL') 2M
cr=_______________ #line2
cr._______("seleect * from IPL2022") #line3
r=cr.fetchall()
for i in r:
print(i)
cn.close()

Answer:
1M
import mysql.connector as ms #line1
cn=ms.connect(host='localhost',user='root',passwd='root',database='IPL') 1M
cr=cn.cursor() #line2 1M
cr.execute("seleect * from IPL2022") #line3
r=cr.fetchall()
for i in r:
print(i)
cn.close()

1 marks for one correct fillup.

33 5
separated by comma. It should have header row and then take in input from the (3+2
user for all following rows. The format of the file should be as shown if user )M
enters 2 records.
Roll.No,Name,Marks
20,ronit,67
56,nihir,69

Ans: 3M

import csv

w1=csv.writer(f1,delimiter = ",")
w1.writerow(['Roll.No', 'Name', 'Marks'])
while True:
print ("Enter 1 to continue adding, 0 to exit")
op = int(input("Enter Option"))
if (op == 1):
rollno = int(input("Enter Roll No"))
name = input("Enter Name")
marks = int(input("Enter Marks"))
wlist = [rollno,name,marks]
w1.writerow(wlist)
elif op == 0:
break;
f1.close()

b. Ans.
2M
writer.writerow(row): Write the row parameter to the
formatted according to delimiter defined in writer function
e.g.
import csv

f1.close()

writer.writerows(rows): Writes multiple rows (sequ


object
e.g.
import csv

f1.close()

OR

a.
only those students who scored more than 80 marks. Records stored in students is 3M
in format : Rollno, Name, Marks.

Ans:
import csv
f=open("student.csv","r")
d=csv.reader(f)
next(f)
print("Students Scored More than 80")
print()
for i in d:
if int(i[2])>80:
print("Roll Number =", i[0]) 2M
print("Name =", i[1])
print("Marks=", i[2])
f.close( )
b. What is full form of CSV? Write two advantages.
Ans: CSV (Comma Separated Values)
Advantages of CSV:
CSV is faster to handle
CSV is smaller in size and is easy to generate
CSV is human readable and easy to edit manually
CSV is simple to implement and parse
CSV is processed by almost all existing applications

SECTION E
34 Consider the following tables Supplier and Consumer. Write SQL commands for 4M
the statements (a) to (d).

(a) To display the C_ID, Supplier name, Supplier Address, Consumer Name and
Consumer Address for every Consumer
(b) To display Consumer details in ascending order of CName
(c) To display number of Consumers from each city

Ans:
a. Select C_ID, S.SupplierName, S.SupplierAddress, C.CName,
C.CAddress from Supplier S, Consumer C where 1M
C.SupplierID=S.SupplierID;
b. Select * from Consumer order by CName; 1M
c. select Ccity, count(*) from Consumer group by Ccity; 1M
d. Select * from Supplier where SupplierCit 1M

OR

a) Observe the following table Product and answer the parts(i) and(ii)
accordingly
Table: Product

ProNo Name Qty PurchaseDate


101 Pen 102 12-12-2022

102 Pencil 201 21-02-2018

103 Eraser 90 09-08-2010

109 Sharpener 70 31-08-2019

113 Clips 100 12-12-2014

(i) Write the names of most appropriate columns, which can be considered as
candidate keys.
(ii) What is the degree and cardinality of the above table?
1M
ANS :

(I) Candidate keys can be : ProNo , Name 1M


(II) cardinality: 5 Degree : 4

b) Table Employee has 4 records and Table Dept has 3 records in it. Mr. Jain
wants to display all information stored in both of these related tables. He
forgot to specify equi-join condition in the query. How many rows will
get displayed on execution of this query?
ANS : 12 ROWS because it generates a cross join as the output
1M

c) Surya, a student of class XI, created a table "RESULT". Grade is one of


the column of this table. To find the details of students whose Grades
have not been entered, he wrote the following MySql query. which did
not give the desired result.
SELECT*FROM Result WHERE Grade = "Null";
Help Surya to run the query by removing the errors from the query and write the
correct Query
ANS : SELECT * FROM RESULT WHERE GRADE IS NULL ;
1M

35 4M
i.A user defined function CreateFile() is created to input data for a
record and add to Book.dat .
ii. A function CountRec(Author) is created in Python which accepts the
Author name as parameter and count and return number of books by the
given Author are stored in the binary file

Observe and complete the following code based on the requirement given above:

import ___________ statement 1


def createFile():
fobj=open(________________) statement 2
BookNo=int(input("Book Number : "))
Book_name=input("Name :")
Author = input(
Price = int(input("Price : "))
rec=[BookNo,Book_Name,Author,Price]
pickle.______________ statement 3
fobj.close()
def CountRec(Author):
fobj=open("Book.dat","rb")
num = 0
try:
while True:
rec=pickle.____________ statement 4
if Author==rec[2]:
num = num + 1
except:
fobj.close()
return num
i. Which module should be imported in the program? (Statement 1)
ii. Write the correct statement required to open a file in corresponding
mode.(Statement 2)
iii.
.(statement 3)
iv. Write the correct statement to read the data from the binary file
1M
1M
Ans: 1M
i. pickle 1M
ii.
iii. pickle.dump(fobj,rec)
iv. pickle.load(fobj)

You might also like